Hi @peterg,
I have found a solution to my problem which I have posted here:
I want to throw an error if the checkbox is not ticked, and the verifier tries to move to the next stage.
frappe.ui.form.on('Purchase Order', {
validate: (frm) => {
// Doc Creation:
if (!frm.doc.custom_created_by && frm.doc.workflow_state === 'Draft') {
frm.doc.custom_created_by = frappe.session.user,
frm.doc.custom_created_time = frappe.datetime.now_datetime();
}
// Doc Verification:
else if ((frm.doc.custom_read_and_verified == 1) && (frm.doc.workflow_state === 'Verification Pending')){
frm.doc.custom_verified_by = frappe.session.user,
frm.doc.custom_verified_time = frappe.datetime.now_datetime();
}
else if ((frm.doc.custom_read_and_verified != 1) && (frm.doc.workflow_state === 'Verification Pending')){
frm.doc.custom_verified_by = null,
frm.doc.custom_verified_time = null;
}
// Doc Approval:
else if ((frm.doc.custom_read_and_approved == 1) && (frm.doc.workflow_state === 'Approval Pending by Manager')){
frm.doc.custom_approved_by = frappe.session.user,
frm.doc.custom_approved_time = frappe.datetime.now_datetime();
}
else if ((frm.doc.custom_read_and_approved != 1) && (frm.doc.workflow_state === 'Approval Pending by Manager')){
frm.doc.custom_approved_by = null,
frm.doc.custom_approved_time = null;
}
},
before_workflow_action: (frm) => {
//console.log(frm.selected_workflow_action);
if ((frm.doc.workflow_state === 'Verification Pending') && (frm.selected_workflow_action === 'Verify') && (frm.custom_read_and_verified != 1))
{
frappe.throw("Please tick the Read by Verifier checkbox");
}
}
});
It is working, thanks.