After Refresh the Document Data is not Showing

Hi
i am using cur_frm.set_df_property(‘phone_number’, ‘options’, number_list_value); whenever form is refresh data not showing why?

Please Help me!

Please Help!

Any error on console?

Hi @saurabh6790
not any error.
but value are stored in the Database

below are the script.


frappe.ui.form.on(‘Call Disposition’, {
lead: function(frm) {
var number_list = [];
var number_list_value= [];
frappe.call({
method: “frappe.client.get_list”,
args: {
doctype: “Lead”,
fields: [‘primary_phone’, ‘mobile’],
filters: {
name: cur_frm.doc.lead,
},
},
callback: function® {
number_list = r.message;
var options = number_list[0];
number_list_value= Array.from(Object.keys(options), k => options[k]);
number_list_value=number_list_value.filter(Boolean);

cur_frm.set_df_property(‘phone_number’, ‘options’, number_list_value);
frm.refresh_field(‘phone_number’);
}
});

}
});

Capture19Capture20

1 Like

why use Lead as trigger? try to change trigger…

Hey @dufani1 @saurabh6790
whenever select the lead get the list of mobile and Phone Number of that particular lead.

try this

frappe.ui.form.on(“Call Disposition”, “lead”, function(frm) {
frappe.model.with_doc(“Lead”, frm.doc.link_to_lead, function() {
var po = frappe.model.get_doc(“Lead”, frm.doc.link_to_lead);
frm.set_value("mobile ", po.mobile);
frm.set_value(“Phone Numbe”, po.phone_number);
});
})

Hi @dufani1
but i want to set the value in select type field.

Please Help!
if any other approach.

Finally I got the Solution.

Hi @hari.kishor, do you mind to share your solution here? I am facing the same issue too when making a select field with dynamic options, value get clear even data is stored in database. Really appreciate if you can help. Thank you!

Dropdown

Hii after the page reload. in dropdown data is not showing .
Really appreciate if you can help. Thank you!

Try adding set df property function to refresh hook.

frappe.ui.form.on('Call Disposition', {
  refresh: (frm) => {
    // this will get call every form refresh
    frm.trigger('set_options_fields');
  },
  lead: (frm) => {
    // this will get call every lead field changes
    frm.trigger('set_options_fields');
  }
  set_options_fields: (frm) => {
    // set_options_fields is just a function name you could use anything
    frm.set_df_property('phone_number', 'options', ['a', 'b', 'c']);
    frm.refresh_field('phone_number');
  },
});