Small customization on HR when employee left usually no communication to Admin to disable userid (if added on his form).
System should check if status left and userid => disable.
Small customization on HR when employee left usually no communication to Admin to disable userid (if added on his form).
System should check if status left and userid => disable.
You can use below custom script in Employee
validate:function(frm){
if(frm.doc.status == 'Left'){
frappe.call({
method: "frappe.client.set_value",
args: {
doctype: "User",
name: frm.doc.user_id,
fieldname: "enabled",
value: 0,
},
freeze: true,
callback:(r){
frappe.msgprint(__("User has been Disable from Access"));
}
});
}
Thanks for the reply but my point here was to make it standard or as a option to HR…
We have done this but I believe many other non-developers require as a standard.
I think you should raise a github issue or make pull request with this functionality
Thanks providing this script. Just to point out that there was some syntax that was not in the script which made it not to work for me when placed in the client script window of my instance. After few debugs the below script worked fine for me:
frappe.ui.form.on(‘YourDocType’, {
validate: function(frm) {
if (frm.doc.status === ‘Left’) {
frappe.call({
method: “frappe.client.set_value”,
args: {
doctype: “User”,
name: frm.doc.user_id,
fieldname: “enabled”,
value: 0,
},
freeze: true,
callback: function(r) {
if (!r.exc) {
frappe.msgprint((“User has been disabled from access.”));
} else {
frappe.msgprint((“Error occurred while disabling the user.”));
}
}
});
}
}
});
Hi this is not working for v15 for me.