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

Correct...this is for a record producer, however, the out-of-the-box checkbox you recommend is only for catalog items

 

The script on your article failed to work:

 

function onSubmit() {

 

if(this.document.getElementsByClassName('get-attachment').length == 0) {

g_form.addErrorMessage(getMessage('mandatory_attachment')); return false;

}

}

 

 

You are aware a Record Producer is a Catalog Item? Only extended?

find_real_file.png

Or are you on Pre-Madrid and therefor looking for Catalog Client Scripting?
The scripting mentioned in the article is tested and proven to work.

Can you share a screenshot of your Catalog Client Script? Can you also confirm it is actually running and not something else is wrong (for example the UI type: All / Desktop / Mobile/Service Portal)?

Are you running this Record Producer on the Platform UI or on the Service Portal?

Kind regards,
Mark

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn

Yes, I'm aware it is extended, I just couldn't find the out of the box "mandatory attachment" checkbox...I am assuming it due to my instance version which is London. Also thee script on your article doesn't even let me submit the form...it sort of crashes

Aksha
Tera Guru

Hi,

I did via DOM Manipulation in an onSubmit catalog client script, it worked but may break in future.

But in Madrid, it seems to have a checkbox for mandatory attachments on catalog item. Once Upgraded to Madrid, need to change the piece of code.

WorkAround : 

if (this.document.getElementsByClassName('get-attachment').length == 0)
{
alert('Please attach a file before submit');
return false;
}

This doesn't work, it doesn't even let me submit the form and doesn't prompt the alert.