I’ve created a doctype “Cash Advance Request” where users request management for a cash advance. On that request, I’ve made a button to record payment. I’ve written the following client script, which takes all fields from one doctype to another except one field, i.e., frm.doc.party
Why I’m not to get that field transferred?
frappe.ui.form.on('Cash Advance Request', {
refresh: function(frm) {
// Add the custom button only when the workflow state is 'Approved'
if (frm.doc.workflow_state === 'Approved') {
frm.add_custom_button(__('Payment Entry'), () => {
//frappe.msgprint("Clicked");
frappe.new_doc("Payment Entry", {}, payment_entry => {
payment_entry.doctype = "Payment Entry";
payment_entry.payment_type = "Pay"; // Payment type (can be "Pay" or "Receive")
payment_entry.party_type = "Employee"; // Party type for this payment (Employee)
payment_entry.party = frm.doc.employee;
payment_entry.party_name = frm.doc.employee_name;
payment_entry.mode_of_payment = "Cash"; // Mode of payment (can be changed as needed)
});
}, __("Create"));
}
},
});
I’ve made sure both doctypes have the same field types. Sometimes, data flickers on the field but never stays.