I have created a custom field in the Purchase Order Doctype to indicate Department and made the field compulsory.
Challenge:
How do i enforce If Department is Permitted in User Permission? This was easier to accomplish in V10 but with changes to the permission manager in v11 and carried over to v12, i am finding it difficult to implement
How do i ensure that only users whose Department=True will be notified via mail for approval.
Is it possible to modify the default workflow mail alert auto-generated? or do i have to create custom mail alert to accomplish (2) above?
You can define the different values for the âStatusâ field (âDraftâ, âApproved by Xâ, Approved by Y", âApprovedâ, âCompletedâ, ⌠) and allow transitions from one status to the other only for certain roles (âAccounts Userâ, âProject Managerâ, ⌠).
Yes I tried that but it doesnât exactly work for the flow required based on the diagram above. Being able to segment the workflow along a department line once initiated is the challenge.
Apologies. Here is the script. We use this in the Material Request Document. The Department is the Standard Feature in the Employee master. The script fetches the Department value for the user from the Employee master and populates a Department field in the Material Request document. Now (though I havenât rolled this out for the client yet) user permissions for the approver to just be able to look at Material Requests from her/his department should ensure that the approver can only access and approve her/his departmentâs requests only.
Weâve learnt to add some characters to the Custom Fields we build as we want to reduce the probability of the core code using a similar field in the future. Thatâs the reason you see pch_department. Not department.
Hope this helps. Script after my signature.
Thanks
Jay
Hereâs the script:
frappe.ui.form.on(âMaterial Requestâ, ârefreshâ, function(frm, cdt, cdn) {
console.log(âEntered------â);
var d = locals[cdt][cdn];
console.log(âEntered------â + d);
console.log(âitems_list------â + JSON.stringify(d));
if(frm.doc.docstatus!=1){
var department= fetch_pch_department(d.modified_by);
console.log(â***********ââ + JSON.stringify(department));
cur_frm.set_value(âpch_departmentâ,department)
frm.refresh_field(âpch_departmentâ)
}
});
function fetch_pch_department(arg1){
console.log(âentered into functionâ);
var pch_department=ââ
frappe.call({
method: âfrappe.client.get_valueâ,
args: {
âdoctypeâ: âEmployeeâ,
âfieldnameâ: âdepartmentâ,
âfiltersâ: {
user_id:arg1,
}
},
async: false,
callback: function(r) {
if (r.message) {
pch_department=r.message.department;
console.log(âreadings-----------â + JSON.stringify(r.message));
}
}
});
return pch_department
}