I Want a Mandatory field in a Popup. when transitioning from Sent for Approval to Rejected. this is for the sake of adding in comments while rejecting the document.
Thank you in advance
Hi @Parth_Vashista,
We haven’t tried but we have one syntax, so please apply the client script for it.
frappe.ui.form.on('Your DocType', {
validate: function(frm) {
if (frm.doc.workflow_state === 'Reject') {
frappe.prompt([
{
fieldname: 'reject_reason',
label: 'Reason for rejection',
fieldtype: 'Data',
reqd: 1
}
], function(values) {
// Perform additional actions if required
// For example, you can save the rejection reason to the document or perform validation checks.
}, 'Rejection Reason');
// Return false to prevent saving the document until the reason is entered
return false;
}
}
});
In the script, modification is required, so set your doctype and field name according to.
I hope this helps.
Thank You!