Make attachment field mandatory on submit

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?

@dufani1 send image of your doctype, please

Thanks @Mohammed_Redha for quick response

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"))
		}
	}
}); 
3 Likes

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.

2 Likes

Thanks a lot @shreya115 working fine…
My regards

Ah! My bad. I’d misread before_save.