Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

How to make attachment mandatory

Not applicable

Hello ServiceNow Family,

Good day!

 

How to make attachment mandatory for a specific choice(Choice 2) in a catalog item.

But for other choices this should not be a mandatory.

Please help...

 

Thanks,

Rajesh

2 REPLIES 2

Dr Atul G- LNG
Tera Patron

 Hi @Community Alums 

 

Exact you looking for

https://www.servicenow.com/community/developer-forum/can-i-make-add-attachment-mandatory-based-on-va...

 

credits @Ankur Bawiskar 

 

function onSubmit() {
	//Type appropriate comment here, and begin script below

	var countRequired = 1;
	if(g_form.getValue('request_required') == 'Manage document'){
		if(window == null){
			// portal
			if(this.document.getElementsByClassName('get-attachment').length != countRequired) {
				g_form.addErrorMessage(getMessage('attachment_is_mandatory'));
				return false;
			}
		}
		else{
			// native view
			var length = $j("li.attachment_list_items").find("span").length;
			if(length != countRequired){
				g_form.addErrorMessage(getMessage('attachment_is_mandatory'));
				return false;
			}
		}
	}
}

https://www.servicenow.com/community/developer-forum/how-to-make-attachment-mandatory-for-catalog-it... 

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

Ankur Bawiskar
Tera Patron

@Community Alums 

why not use Attachment type variable and make it mandatory based on the choice using Catalog UI policy?

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader