How to Replace PAYMENT ENTRY Child Table with other field?

Dear all,

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.

Because we want to display important information for each invoice / journal before process the payment.

Thank you in advance

You can read on how to create custom scripts here

Hi,

Thank you for replying…
Steps that I’ve done so far:

  1. Create Customize Form of Payment Entry Reference, add REMARK field

.
.

  1. But the Field of Journal Entry REMARK is not fetch automatically at Payment Entry Reference:

.
.

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 in advance

You want to display a field from the reference document or do you wish to replace the entire table itself ?

Hi,

Thank you for answering :pray:
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.

Thank you in advance.

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.

Thank you in advance :pray:

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.

Hi,

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.

Thank you in advance

Here you go. Here are some screen shots of what I did.

I customized the child doctype and added a new field named remarks which would fetch from the document linked in field reference_name

This is how it looks after saving

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.

Hi,

Thank you for your reply and your time to test this case. :pray:

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:
20191120_01_ask1

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.


.

Please help me to type the correct word at FETCH FROM box.
Thank you in advance :pray:

Is it correct to fetch value from other doc only use specific same field name like this picture?

Or maybe some one can give me the correct way to use frappe.db.get_value or cur_frm.add_fetch

Thank you in advance

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.

Hi…

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.

Thank you in advance :pray:

Hi,

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:
reference_name

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

Thank you in advance :pray: