cbasso
January 23, 2026, 10:04am
1
Hi,
here what I’m trying do do:
FieldA: field of type select
FieldB: field of type select
I need to change Options in FieldB based on FieldA values, using Client Script.
Example:
FieldA optons: Option10, Option11
FieldB optons: Option20, Option21, Option22, Option23
if FieldA = Option10 then FieldB Options = Option20, Option21
if FieldA = Option11 then FieldB Options = Option22, Option23
I know how to alter the Options field, using:
frm.set_df_property(‘FieldB, ‘options’, [‘Option20’, ‘Option21’]);
But I’m unable to read the FieldA value, I’ve tried:
if (frm.FieldA == ‘Option20’)
if (frm.doc.FieldA == ‘Option20’)
But it’s not working.
How can I read the select field value?
Thanks
Hi @cbasso
Client script is the solution and chatgpt is curious to help you if you have clear prompt ready.
Better to engage chatgpt with Role, task and then context and it will surely help.
cbasso
January 23, 2026, 1:59pm
3
Hi, solved by myself, here the solution:
frappe.ui.form.on('MyDocType', {
refresh(frm) {
refresh_field(frm);
},
field1(frm) {
refresh_field(frm);
}
});
function refresh_field(frm) {
if (frm.doc.field1 == 'Value1') {
frm.set_df_property('field2', 'options', ['OptionA', 'OptionB', 'OptionC']);
}
if (frm.doc.field1 == 'Value2') {
frm.set_df_property('field2', 'options', ['OptionA', 'OptionF', 'OptionZ']);
}
frm.refresh_field('field2');
}