Hi,
I have defined some custom fields, and have also checked on “allowed on submit” on them. And, I have this following custom script, which runs on the Salary Slip form. Though, the custom script is running and is setting the values on the submitted form, it changes the status of the document to “Not Saved” and requires an “Update” button to be pressed. What could be wrong?
frappe.ui.form.on(“Salary Slip”, “refresh”, function(frm, cdt, cdn) {
frappe.call({
method: "icp.api.get_leave_balance_on",
args: {
"employee": frm.doc.employee,
"leave_type": "Casual Leave",
"date": frm.doc.end_date
},
callback:function(r){
if(r.message) {
frappe.model.set_value(cdt, cdn, "casual_leave_balance", flt(r.message));
refresh_field("casual_leave_balance");
}
}
});
frappe.call({
method: "icp.api.get_leave_balance_on",
args: {
"employee": frm.doc.employee,
"leave_type": "Privilege Leave",
"date": frm.doc.end_date
},
callback:function(r){
if(r.message) {
frappe.model.set_value(cdt, cdn, "earned_leave_balance", flt(r.message));
refresh_field("earned_leave_balance");
}
}
});
frappe.call({
method: "icp.api.get_approved_leaves_for_period",
args: {
"employee": frm.doc.employee,
"leave_type": "Casual Leave",
"from_date": frm.doc.start_date,
"to_date": frm.doc.end_date
},
callback:function(r){
if(r.message) {
frappe.model.set_value(cdt, cdn, "casual_leave_taken_this_month", flt(r.message));
refresh_field("casual_leave_taken_this_month");
}
}
});
frappe.call({
method: "icp.api.get_approved_leaves_for_period",
args: {
"employee": frm.doc.employee,
"leave_type": "Privilege Leave",
"from_date": frm.doc.start_date,
"to_date": frm.doc.end_date
},
callback:function(r){
if(r.message) {
frappe.model.set_value(cdt, cdn, "earned_leave_taken_this_month", flt(r.message));
refresh_field("earned_leave_taken_this_month");
}
}
});
});