Fetch only works when inserting it manually in the field.
Here’s the sample of the data value being set upon “save/request” (it does not fetch)
Here’s the sample of the data being manually inserted (it fetched the datas)
Custom Script:
frappe.ui.form.on(“Material Request”, “validate”, function(frm,cdt,cdn){
frm.add_fetch(“preparer_user”, “signature”, “preparer_signature”);
frm.add_fetch(“noter_user”, “signature”, “noter_signature”);
frm.add_fetch(“approver_user”, “signature”, “approver_signature”);frm.add_fetch(“preparer_user”, “signatory”, “prepared_by”);
frm.add_fetch(“noter_user”, “signatory”, “noted_by”);
frm.add_fetch(“approver_user”, “signatory”, “approved_by”);
});frappe.ui.form.on(“Material Request”, “validate”, function(frm) {
if (frm.doc.workflow_state == “Pending Request”)
{
frm.set_value(“preparer_user”, frm.doc.owner);
}else if (frm.doc.workflow_state == “Pending Approval”)
{
frm.set_value(“noter_user”, frm.doc.modified_by);
}else if (frm.doc.workflow_state == “Approved”)
{
frm.set_value(“approver_user”, frm.doc.modified_by);
}
});