Refresh linked field in child table


I’m trying to fetch daily allowances based on a country into a child table using script. But it doesn’t work.

What works is:
if I manually select country in child table, then:


will fetch daily allowance. The same can be achieved also without script by customizing form and writing “country_al.daily_allowance” into options like this:

But if I do something like this:

frappe.ui.form.on("Expense Claim", "get_trip_rows", function(frm, cdt, cdn){

   frm.refresh();  // this refresh has absolutely no effect on the child


function gettripduration(frm){	

var child = cur_frm.add_child("allowances");

		frappe.model.set_value(child.doctype,, "country_al",;

 // this refresh has absolutely no effect on the child, it is not fetching anything...

The allowances field will not update. The script cur_frm_add_fetch nor “country_al.daily_allowance” doesn’t work anymore.

How can I solve this please?

2 things:

  1. cur_frm is deprecated. Use frm that you passed instead
  2. In your gettripduration function, return frm.refresh(). That should work

Dear @tundebabzy,

thank you for your help. Actually there are 2 issues in that script. Your input would be very appreciated.

  1. child table will not refresh
    I don’t fully understand how is this possible - see screenshot. Day Start and Day End will not refresh, but Country is refreshed?!?

    When I clik inside each cell, the datetime is there, it is just not visible.

  2. issue with aloowances - what I want to achieve is as follows:

  • set country by script
  • based on country, write daily allowances into “daily_alowance” fiels - see my first post and screenshot of the doctype.

What is working: when I don’t fill-out country in child table by script, but rather manually select country, daily_allowance field is automatically populated - I know this is because of Options: country_al.daily_allowance

what is not working: as soon as I change and put this into the script:

frappe.model.set_value(child.doctype,, “country_al”,;

I will get country populated in the child, but not the daily_allowance.
Below - screenshot done by script:

And when I manually select Country - I get this - which is correct:

The script for your reference:

frappe.ui.form.on("Expense Claim", "get_trip_rows", function(frm, cdt, cdn){
function gettripduration(frm){	

		for (i = 0; i < tripDays ; i++) 
     		var child = frm.add_child("allowances");
 		frappe.model.set_value(child.doctype,, "daystart", tripDateStart);
 		frappe.model.set_value(child.doctype,, "dayend", tripDateFinish);
 		frappe.model.set_value(child.doctype,, "country_al",;
 		//country will not fetch daily allowances - TBD
 		frappe.model.set_value(child.doctype,, "meals", 0);

     return frm.refresh();