Custom field value disappears after refreshing screen

Hello,

I have created a custom field whose select list is dependent on the status of the interview. Below is the client script that i have used.

frappe.ui.form.on(“Interview”, “status”, function(frm) {
if (frm.doc.status == “Pending”) {
set_field_options(“custom_statut_additionnel”, [“Rappel/ To do”]);
} else if (frm.doc.status == “Rejected”) {
set_field_options(“custom_statut_additionnel”, [
“Sur calibrer en matière d’expériences”,
“Sous calibrés en matière d’expériences”,
“Sur calibrer en matière de rémunération”,
“Pas a l’écoute”,
“Pas intéressé”
]);
}
}
);

The issues that I am facing are:

  1. When i create an interview, by default it is in the status pending, however the related custom list does not appear. I have to select another status then reselect pending, then the list appears.
  2. When I save the interview, it takes the value, however when I perform a refresh, the custom field value disappears. The value still remains on the list view, but when I go the screen, its not present.

Kindly help on this issue.

Regards,

Please apply like

frm.set_df_property("your_field_name", "options", ["A", "B"]);

// Example:
frm.set_df_property("custom_statut_additionnel", "options", ["", "Rappel/ To do"]);
1 Like

I have modified the script as suggested, both issues still persist

@Ayesha try this

frappe.ui.form.on(“Interview”, {
onload: function(frm) {
set_custom_field_options(frm);
},
status: function(frm) {
set_custom_field_options(frm);
}
});

function set_custom_field_options(frm) {
if (frm.doc.status == “Pending”) {
frm.set_df_property(“custom_statut_additionnel”, “options”, [
“Rappel/ To do”
]);
} else if (frm.doc.status == “Rejected”) {
frm.set_df_property(“custom_statut_additionnel”, “options”, [
“Sur calibrer en matière d’expériences”,
“Sous calibrés en matière d’expériences”,
“Sur calibrer en matière de rémunération”,
“Pas a l’écoute”,
“Pas intéressé”
]);
}
}

1 Like

@Jeel It works, thank you :slightly_smiling_face: