Making attachment mandatory on initial record producer request form...

samuelscott
Tera Expert

 

I know this question must be pretty common, but I am not being able to get around it. I'm trying to make users attach a document on the initial form for a record producer and I found this on the community: https://community.servicenow.com/community?id=community_question&sys_id=ec764fe1db1cdbc01dcaf3231f96...

 

I can't make it work (of course, I placed my custom table instead of the one displayed on the code). My custom table is: u_procurement_request_pp

1 ACCEPTED SOLUTION

samuelscott
Tera Expert

Actually, the post I mentioned works and most of the solutions suggested work. The reason why I was having trouble was because there is a hidden field on the client script from that should be disabled. That field is: "isolate script"

View solution in original post

20 REPLIES 20

The first script you posted doesnt let me submit the form:

 

function onSubmit() {
	
	if (parseInt(countAttachments()) < 1) {
		alert("Please attach signed off application form");
		return false;
	}
	
}

 

find_real_file.png

I forgot to add the attachment function onSubmit function countAttachments () { return angular.element("#sc_cat_item").scope().attachments.length; }

So, something like this?

 

function onSubmit() {

function countAttachments () {
return angular.element("#sc_cat_item").scope().attachments.length;
}

if (parseInt(countAttachments()) < 1) {
alert("Please attach signed off application form");
return false;
}

}

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Because the title mentions "record producer", I assume you want do this Client Side, thru Catalog Client Scripting for example? Or if you are on Madrid... there's an out-of-the-box checkbox for mandatory attachment!

Have a look at an article I wrote. This mentions the Madrid checkbox + Pre-Madrid scripting.
Service Portal Catalog Items: Hide Attachment / Mandatory Attachment [Madrid]

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn