How to value when a document is created from another document

Hi guys.
I like to fetch custom field value from ‘Sales Invoice’ to anothe custom field in’Payment Entry’ when ever Payment Entry Document is created from Sales Invoice Document.
below is my custom script.
//fetch value when document is create from another document e.g from Sales Invoice to Payment Entry

frappe.ui.form.on(“Payment Entry”, “onload”, function(frm){
frappe.db.get_value(“Sales Invoice”, {name: cur_frm.doc.house_name},
“house_name”, function(data){
cur_frm.set_value(“house_name”, data.house_name);});
});
});

pls I need help