@nishith custom script to set blank value to field
frm.set_value("field_name", value);
frm.refresh_field("field_name");
1 Like
nishith
September 8, 2016, 6:45am
3
I know about the solution which have mentioned by you.
But I want to set “Employee Name ” to blank again if “Salary Advance for Employee ” is set to blank again.
I have used cur_frm.cscript.salary_advance_for_employee event to clear it. But it is not triggering while “salary_advance_for_employee” is blank.
cur_frm.cscript.salary_advance_for_employee = function(doc, dt, dn) {
if (doc.salary_advance_for_employee == None)
{
cur_frm.set_value(“employee_name”, “”)
frm.refresh_field(“employee_name”)
}
}
Should be cur_frm.refresh_field(“employee_name”)
1 Like
nishith
September 8, 2016, 6:51am
5
It’s ok… But actual issue is that the event “cur_frm.cscript.salary_advance_for_employee” is not triggering while “salary_advance_for_employee ” is blank.
You are triggering it on itself, it will not trigger till you change it right, Might want to trigger it on onload or on refresh.
nishith
September 8, 2016, 7:07am
7
Sorry, but I have to set it on “on change” event of “salary_advance_for_employee ”.
@nishith Try troubleshooting it, see what is returned by doc.salary_advance_for_employee
I’m not sure which doctype you are working on, but the rest of the fields should be accurate. Just replace DOCTYPE in the first line with the doctype you are working with. Try it out and see how it goes.
frappe.ui.form.on("DOCTYPE", {
salary_advance_for_employee: function(frm) {
if ( frm.doc.salary_advance_for_employee === "") {
frm.set_value("employee_name", "") {
else {
frm.add_fetch("salary_advance_for_employee", "employee_name", "employee_name");
}
}
});
2 Likes
Hey, I was facing the same problem. This is what I did:
Created an empty variable
var empty = ""
Passed the empty variable as the value of the field we want to reset
frappe.model.set_value(
cur_frm.doctype,
cur_frm.docname,
"Your_Field_Name",
empty
);
This reset the field for me