I would like to ask help about how to replace PAYMENT ENTRY Reference table with other field from Allocated Invoice / Journal (child table), maybe using custom script or some other way.
Therefore I have to created Custom Script with the Button at Payment Entry form:
frappe.ui.form.on('Payment Entry', {
refresh: function(frm) {
frm.add_custom_button(__("Change Value"), function() {
var child_table=cur_frm.doc.references;
for(var i=0;i<child_table.length;i++){
// Need Query Script, to put at xremark.
var xremark='TEST QUERY RESULT'+i;
child_table[i].remark = xremark;
// I have tested this script, but can not work
cur_frm.add_fetch('parent', 'remark', 'remark');
// Just to show that Loop is Running
msgprint('count '+i+' | remark= '+child_table[i].remark);
}
cur_frm.refresh_fields('references');
frappe.msgprint("Done <b>FINISH LOOP</b> ");
});
} });
The Loop is running for Reference Child Table, with msgprint. But How to replace or Query field remark at Journal Entry, so make it show at Remark field at second picture.
Maybe someone can help me to make custom script for Query from other table.
Thank you for answering
No problem for me whether the field REMARK from Journal Entry / Sales Invoice display by press button or show by itself, at table Payment Entry reference.
The Target:
The JOURNAL ENTRY Document have REMARK field, and I need to put Remark field at PAYMENT ENTRY Reference (like picture bellow):
Maybe someone can help me to insert correct script inside //### line bellow:
var child_table=cur_frm.doc.references;
for(var i=0;i<child_table.length;i++){
//############################
// Need Query Script, to put at xremark.
var xremark={ I need correct script QUERY here}
//############################
child_table[i].remark = xremark;
}
cur_frm.refresh_fields('references');
Maybe using frappe.db.get_value or cur_frm.add_fetch with correct format, so the result can be put at child_table[i].remark above.
Maybe someone can help me to make query / fetch data from other document with of above script, whether using frappe.db.get_value or cur_frm.add_fetch or some other functions.
I think there is an easier way. What you can do is to make a field or use a field which has the same name and then map it directly. I’ll try this method and let you know the results.
Thank you for your reply.
I have tried to do the same thing, but the REMARK field is not loaded from other doctype/table. Hopefully you can give me better steps to make it work.
However, there is one big con to this approach. you will have to create this custom field in every document that is eligible as a reference document in a payment entry. Or else you will face errors like Unknown field remarks in doctype Purchase Invoice or Order etc.
Thank you for your reply and your time to test this case.
I have tried several time, but still can not work at my side. Maybe I made some mistake.
There are some question at your sample:
Actually I still confuse, why you type reference_name.remarks at this field.
Can I just put remarks at Fetch From box? Because at Journal Entry doctype, the remark field is ready by default, therefore I want to get the Journal Entry Remark content and put it at this field (payment entry reference).
.
.
At Payment Entry form, I have put remark at fetch from box, but still can not work.
reference_name.remarks style is based the Python style of accessing fields of an object.
The reason why the fetch from journal entry was not working was because you did not use the above style of accessing the field.
Also please understand that these comment or remark fields are bound to have different variable names. Hence I think a custom script makes more sense. I’ll post one when I can test.
I still stuck with custom script for this problems. Maybe some other help can give correct way for call the custom script for query from other doctype/table.
I have tried to use reference_name.remark (or also test with name.remark) at Payment Entry Reference, but the result still not work. I still can not get data from Journal Entry Remark field.
About your pictures:
Is reference_name refer to this PAYMENT ENTRY REFERENCE Docytype
or refer to other document like JOURNAL ENTRY?
Because I search reference_name is not available at JOURNAL ENTRY customize form. Perhaps this is belong to PAYMENT ENTRY REFERENCE customize form