Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

Mandatory attachment based on the condition of the catalog item variable value

phr
Tera Contributor

Hi All,

 

I have a requirement to make attachment mandatory based on the variable condition in the catalog item . I tried to create a UI policy but not able to fetch the "mandatory attachment"  that is present on the catalog item below. I also tried to hide the "make mandatory" on the catalog item level and tried to create a variable type "Attachment" but it also isn't working. Is there any way or any catalog client script to make this happen?

phr_0-1717162064479.png

 

 

 

Thank you.

 

 

1 REPLY 1

Not applicable

Hi @phr ,

Something similar to this should work as an onSubmit Catalog Client Script.

 

function onSubmit() {
        if((g_form.getValue('<variable name>') == 'yes') && this.document.getElementsByClassName('get-attachment').length == 0) {
               g_form.addErrorMessage(getMessage('attachment_is_mandatory'));
               return false;
        }      
}