Any function to refresh a link field in child table (to further refresh fetch fields)

Hey all, I’ve been looking around over the weekend for a solution but am still stumped on this. I’m looking for a function refresh a link field in a child table, so that the fetch fields are populated when the link field isn’t inputted manually.


Using the “Project” field in “Sales Invoice” will populate the ‘timesheets’ child table with billable timesheets.
(GitHub commit)

Currently have fields and client side fetches for additional info (note, employee, start date) that will populate if the timesheet name is manually selected, but not when inputted using the new method.

I feel like the use of set_value in a dynamic sense, especially in a table, is beyond my understanding at this point. Is there any method that can be called to refresh a link field on custom_validate or anything?


Hi @superlack! Can you please post here what you got so far then we’ll try to see what is missing. Thanks!

Hey! thanks for replying. I haven’t had any result trying to trigger refresh_field for child doc table, or child doc field.(script held in parent doc), so I don’t know what other triggers are able to refresh those link fields, and have fetch fields react accordingly.

I would be happy to reciprocate if anybody would like to help!

hi @superlack! It would be best if you can share your script here so that we can check what’s missing. But anyway, if you wanted to refresh child table try this:


You should put it inside your loop setting the value to the child doctype.


Hey again, (and thank you again)

I’ve been using a button (refresh_times) for easy testing of the functions, and still to no avail.

frappe.ui.form.on("Sales Invoice", "refresh_times", function(frm) {

Both the name of the child doctype “timesheets” and link field “time_sheet” are refreshed because I’m a bit hopeless in these respects :wink:

Go through this post, this might help you.

1 Like

I’ve been browsing around, also while trying several combinations of script to have this active, but still no luck. Is anybody aware of any methods to retrigger a link field to get fetched fields to work?

Me too looking for some pointers on the same problem. I have a child table that fetches record (item_code & qty) from Delivery Note.

//fetch child table from Delivery Note Item to Hamriyah Customs Item (item_code & qty)
frappe.ui.form.on(“Hamriyah Customs”, “delivery_note”, function(frm) {
frappe.model.with_doc(“Delivery Note”, frm.doc.delivery_note, function() {
var tabletransfer= frappe.model.get_doc(“Delivery Note”, frm.doc.delivery_note)
$.each(tabletransfer.items, function(index, row){
d = frm.add_child(“items”);
d.item_code = row.item_code;
d.qty = row.qty;

I also need net_weight and other custom field from Doctype Item which isn’t readily available in DN,so i fetch them using custom script below


which unfortunately works ONLY when item_code is manually re-selected /re-triggered. In this case, the item_code is fetched programmatically.

i have attempted fetching via a button (get_info) with add_fetch but didn’t work either.

frappe.ui.form.on(“Hamriyah Customs Item”,“get_info”, function(frm){


return fn(*args, **newargs)
TypeError: runserverobj() takes at least 1 argument (1 given)

1 Like

Have you had any success with finding a solution for refreshing fetches?

no luck yet, using reselect as workaround…

Is that done through script? Or are you going line by line like me and re-triggering each link field?

yea old school by mouse pointer

Hi guys!
I was able to refresh a dependent query by setting value to field using frappe.model.set_value rather than row.fieldname = value

It works like this:
frappe.model.set_value(row.doctype,, fieldname, value);

Let me know if it works for you.


That sounds like good news! Im still uncertain of how to apply it, would you mind sharing the script that you used this function in?

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",
		    	"GTA Service Tax 14%",
		    	"GTA Krishi Kalyan Cess 0.5%",
		    	"GTA Swachh Bharat Cess 0.5%"

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

When all else fails, frm.refresh() usually works. But it refreshes everything (parent doc and all) instead of just the childtables.

1 Like

I found that using origin_doc.origin_field as an option in the custom field triggers the fetch properly except for longtext. Is there any way to overcome this, or is it a bug when it comes to framework?

For reference, the field was within “Sales Invoice Timesheet” and fetched additional information required, probably on a refresh trigger, but “save” has done the job

Also (barely) visible is the timesheet note field, which is a longtext field that has the same option that doesn’t work

Grr… It was “Text Editor” in the timesheet, and “Long Text” in my custom field that it was fetched to. Switching to “Text Editor” fixed it

1 Like

Is there any accepted solution? I’m stuck in the same boat

Last two replies should help. Also, save to refresh if you don’t have a refresh line in your script