Button in parent form to refresh a field in child table

Hi Guys ,

I am trying to refresh a field in child table with a button in the parent form with no luck , tried the below scripts . Any help ?

Parent form : Cutting Issue
Child table : Cutting Iss
Child table field name : ci
Child table’s field I wanted to refresh : prodno

frappe.ui.form.on("Cutting Iss", "update", function(frm, cdt, cdn) {
	frappe.ui.form.trigger("Cutting Iss", "prodno");
});

and this

frappe.ui.form.on("Cutting Iss", "update", function(frm, cdt, cdn) {
	frm.refresh_field('prodno');
});

Thanks

@Muthu,

Try refreshing the childtable instead of child table’s field.

e.g. frm.refresh_field(“ci”)

1 Like

Thank you for the reply @makarand_b . I tried and got this error

frappe.ui.form.on("Cutting Iss", "update", function(frm, cdt, cdn) {
	frm.refresh_field('ci');
});



Traceback (most recent call last):
  File "/home/ommi/frappe-bench/apps/frappe/frappe/app.py", line 55, in application
    response = frappe.handler.handle()
  File "/home/ommi/frappe-bench/apps/frappe/frappe/handler.py", line 19, in handle
    execute_cmd(cmd)
  File "/home/ommi/frappe-bench/apps/frappe/frappe/handler.py", line 36, in execute_cmd
    ret = frappe.call(method, **frappe.form_dict)
  File "/home/ommi/frappe-bench/apps/frappe/frappe/__init__.py", line 876, in call
    return fn(*args, **newargs)
TypeError: runserverobj() takes at least 1 argument (1 given) 

Any help ? Thanks

Hi @Muthu! You have to refresh the entire child table. Use :

frm.refresh_field("cutting_iss")

1 Like

Hi @creamdory .

Thanks for the reply . Again same issue I am getting a traceback .

Traceback (most recent call last):
  File "/home/ommi/frappe-bench/apps/frappe/frappe/app.py", line 55, in application
    response = frappe.handler.handle()
  File "/home/ommi/frappe-bench/apps/frappe/frappe/handler.py", line 19, in handle
    execute_cmd(cmd)
  File "/home/ommi/frappe-bench/apps/frappe/frappe/handler.py", line 36, in execute_cmd
    ret = frappe.call(method, **frappe.form_dict)
  File "/home/ommi/frappe-bench/apps/frappe/frappe/__init__.py", line 876, in call
    return fn(*args, **newargs)
TypeError: runserverobj() takes at least 1 argument (1 given) 

Any help ? thanks

Hi @Muthu! You have put the script on your Child doctype. Put it in your Parent (Cutting Issue). Should be:

frappe.ui.form.on("Cutting Issue", "update", function(frm, cdt, cdn) {
	frm.refresh_field('cutting_iss');
});
1 Like

Thanks for continued support @creamdory . I pasted the same script , now no traceback on clicking the button . But nothing happens I opened the console to check the errors but to my surprise there is nothing getting displayed on clicking the button . Any help ?

Thanks

Hi @Muthu! Could you give us your usecase? What is your expected output? And example would be really great. Thanks!

@creamdory . Thanks again for the extended support . I would like to refresh a link field in the child table which further fetches items .

Any guidance ?

Thanks

What is your trigger to fetch item? It would be best to put the refresh. Sample screenshot and explanation of the inputs and outputs will be best. Thanks!