Get party list when account added in JV using custom script

Background:

I have created a custom JV entry type which automatically adds some accounts in the JV (like bank entry):

frappe.ui.form.on("Journal Entry", "voucher_type", function(frm, cdt, cdn) {
		if((!(frm.doc.accounts || []).length) || ((frm.doc.accounts || []).length==1 && !frm.doc.accounts[0].account)) {
		  if(frm.doc.voucher_type=="GTA Expense Entry") {			
		    frappe.model.clear_table(frm.doc, "accounts");
		    var list_of_accounts = [
		    	"Freight Outward - SMC",
		    	"Creditors - SMC",
		    	"GTA Service Tax 14% - SMC",
		    	"GTA Krishi Kalyan Cess 0.5% - SMC",
		    	"GTA Swachh Bharat Cess 0.5% - SMC"
		    ];

	        $.each(list_of_accounts, function(index, value) {
					var row = frappe.model.add_child(frm.doc, "Journal Entry Account", "accounts");
					row.account = value;
			});
			refresh_field("accounts");
		  }
		}
});

Issue:
I want the party query to populate for the creditors account but I tried some code and I can’t make it work.

Any help is appreciated. Thanks.

What did you try?

I had a couple of ideas:

  • using referesh_field for account in child table
  • using set_value for account in child table

I later found I have the same issue as Any function to refresh a link field in child table (to further refresh fetch fields)

Solved: Any function to refresh a link field in child table (to further refresh fetch fields) - #13 by snv

1 Like