Hiii Experts
Please I need help in custom script to make attachment field mandatory on submit.
My case as the following:
doctype name: scop_work
Field name: attahe_22
Note: I am not a developer
Thanks in advance
Hiii Experts
Please I need help in custom script to make attachment field mandatory on submit.
My case as the following:
doctype name: scop_work
Field name: attahe_22
Note: I am not a developer
Thanks in advance
There’s a mandatory field within each DocType. Just check that.
Dear @achillesrasquinha when you make attach filed mandatory, it is not possible to work without custom script.
Dear @Mohammed_Redha can you help me if possible?
Dear @Mohammed_Redha I want to make it mandatory after save not when saving. When I do what you told me see what happen, it is not possible.
Hi @dufani1, you can add a custom script like below to raise a validation before submitting.
frappe.ui.form.on('Scope of Work', {
before_submit: function(frm) {
if (frm.doc.attach_22 == null) {
frappe.throw(__("Mandatory field: attach_22"))
}
}
});
All of the above does the same thing. The DocType is never “Saved”, these are triggers always done like you said, “Before Save”.
User Clicks Save - WARN - Do stuff.
Just like any other workflow.
before_submit
does pretty much the same. Adding a Mandatory Check.
Hi @achillesrasquinha, attach fields cannot be made mandatory if DocType is submittable. The form needs to be saved before attaching anything, and that won’t be possible if mandatory field is checked.
Ah! My bad. I’d misread before_save.