Need dynamic select option in childtable

on refresh parent doctype i want dynamic select option for childtable like this

if(childtable_row.financier == "test"){
status.options = ["A",'B']
}else{
status.options = ['c']
}

Hi @pratikcws,

  if(row.financier == "TEST")
  {
    set_field_options("status", ["Loan Approved","Loan Appealing"])
  }
  else
  {
    set_field_options("status", ["Loan Accepted"])
  }

And More details of script: Filter Options in Select Field
https://docs.erpnext.com/docs/v12/user/manual/en/customize-erpnext/custom-scripts/filter-options-in-select-field

Thank You!

this will work for parent doc but not for child table

Hi @pratikcws,

If you have not check so check it for just small help.

and you have a find any solution then put in this topic.

Thank You!

Hi @pratikcws,

I got a solution.

Please check it.
it works for my side in child table.

if(row.financier == "TEST")
    {
        frm.fields_dict.items.grid.update_docfield_property("status","options",["Loan Approved","Loan Appealing"]);
    }
else
    {
        frm.fields_dict.items.grid.update_docfield_property("status","options",["Loan Accepted"]);
    }

Thank You!

1 Like

Which version of ERPNext is it working for?

12 and 13 both.

I am getting the following error:

frm.fields_dict.items.grid.update_docfield_property is not a function
at refresh (eval at setup (script_manager.js:160:5), :30:39)
at a (script_manager.js:90:16)
at script_manager.js:108:22

Thank you so much @NCP

This is an easy way to do a version of set_field_options() on the child table. Hope this helps others too.

Here’s how I used it today:

		frappe.call({
			method: "frappe_mailjet.frappe_mailjet_integration.doctype.mailjet_settings.mailjet_settings.get_doc_fields",
			args: {
				"doc": frm.doc.for_doctype
			},
			callback: function(r) {
				frm.fields_dict.custom_fields.grid.update_docfield_property("field_name","options", r.message);
			}
		});

Note: my child table is called custom_fields and my field is called field_name