Hello dears
Actually i`m trying to write a custom script that checks if my custom field which is
Accounting approval != Approved
donot let the user to submit the sales order
i`v tried that one
frappe.ui.form.on("Sales Order", "on_submit", function(frm, cdt, cdn) {
if (frm.doc.accounting_approval != "Approved") {
msgprint("Sales Order Not Approved Yet!");
return false;
} });
But actually this allows user to submit the order but only inform him by the msgprint()
how can it stop the process until the accounting manager acceptance for that sales order ??
@Mahmoud_Ghoneem, If you haven’t already, have a look at the Workflow documentation here; it sounds like a good match for your use case and you won’t need to reinvent anything.
That said, you can get your script to work by changing frappe.msgprint
to frappe.throw
.
1 Like
i know that …
But every thing here is going well except this custom script
can you help how to make it stop the process ??
frappe.throw
is an error message and stops the process. That should be all you need to do.
2 Likes
Sorry It doesn’t work
Its showing error message but the sales order submitted
frappe.ui.form.on(“Sales Order”, “before_submit”, function(frm, cdt, cdn) {
if (frm.doc.accounting_approval != “Approved”) {
frappe.throw(“Sales Order Not Approved Yet!”);
return false;
} });
Whoops. Change on_submit
to before_submit
, as above.
2 Likes