Hi,
I’m developing an app using ERPNext v12.17
Right now I would like to change a Data field into a Select field for purposes of form entry. According to the documentation, I should use frm.set_df_property()
to change the fieldtype (and options), and frappe should “refresh the field” as part of the function call.
Here’s what I tried:
frappe.ui.form.on('Test Doctype', {
setup: (frm) => {
frm.set_df_property('test_field', 'fieldtype', 'Select');
frm.set_df_property('test_field', 'options', ['one', 'two']);
},
before_load: (frm) => {
frm.set_df_property('test_field', 'fieldtype', 'Select');
frm.set_df_property('test_field', 'options', ['one', 'two']);
},
onload: (frm) => {
frm.set_df_property('test_field', 'fieldtype', 'Select');
frm.set_df_property('test_field', 'options', ['one', 'two']);
},
refresh: (frm) => {
frm.set_df_property('test_field', 'fieldtype', 'Select');
frm.set_df_property('test_field', 'options', ['one', 'two']);
},
onload_post_render: (frm) => {
frm.set_df_property('test_field', 'fieldtype', 'Select');
frm.set_df_property('test_field', 'options', ['one', 'two']);
},
});
After the code runs, the field remains a Data field, with no apparent change. Am I doing something wrong?
Looking through the frappe code base for instances of set_df_property
, I don’t see any (apparent) lines of code to force a screen redraw, so I don’t understand why it doesn’t work for me.
NB: I’ve also tried running frm.refresh_field('test_field')
after set_df_property
, which also did not help.