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
}