Is it possible to change the options of select field within a Dialog Box?

Is it possible to change the options of select field within a Dialog Box?

An example of what you seek or cannot do would help illustrate the context you refer to here?

@clarkej this is my sample dialog box. I want to change B’s options whenever user changes A

Screenshot%20from%202018-08-19%2007-29-06

u can

This can be done by below custom script:

var df = frappe.meta.get_docfield("TABLE NAME","FIELDNAME", cur_frm.doc.name);
df.options= ['1','2','3'];

write some function to change value of df.options based on value in field A

1 Like

@johnskywalker you can simply use if conditions to do that,
for example :

frappe.ui.form.on("Doctype Name", {
                field_b: function(frm) {
                                assign_value(frm);
                }
                
});

var assign_value = function (frm)
{
	if(frm.doc.field_b == "Alpha")
	{
		frm.set_df_property("field_a", "options", ["Option A", "Option B", "Option C", "Option D"]);
	}
	else if(frm.doc.field_b == "Numeric")
	{
		frm.set_df_property("field_a", "options", ["Option 1", "Option 2", "Option 3", "Option 4"]);
	}
}