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']
status.options = ['c']

Hi @pratikcws,

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

And More details of script: 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"]);
        frm.fields_dict.items.grid.update_docfield_property("status","options",["Loan Accepted"]);

Thank You!


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:{
			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

1 Like

@NCP @adam26d Not Working in my side , my child table field name is items

frappe.ui.form.on("Purchase Order Item", 'expense_account',function(frm,cdt,cdn) {

    var row = locals[cdt][cdn];

    if (row.expense_account == 'Machinery Hiring - PVIPL') {
        frm.fields_dict.items.grid.update_docfield_property("expense_perticulers", "options", ["Loan Approved", "Loan Appealing"]);
    else {
        frm.fields_dict.items.grid.update_docfield_property("expense_perticulers", "options", ["Loan Accepted"]);


Hello @Sagar_Patil

My first hunch of your problem is that this function might be unreachable.

Put a console.log("working");

after var row = locals[cdt][cdn];

To verify that the code is running.

In my case i ran this thing using a parent doctype event. Child events are counterintuitive sometimes.

No, function is working fine, i think Child’s problem. Is there any other way ? cause i need to add select options on child field’s event