Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Issue with the OnSubmit client script

Pooja Khatri
Tera Contributor

Hi All,

 

I have the below OnSubmit client script written for making attachments as mandatory 

 

Script ::

 

function onSubmit() {
if(this.document.getElementsByClassName('get-attachment').length == 0 && g_form.getValue('do_you_have_a_copy_of_the_rfx')=="Yes"  ) {
           alert('Please attach the copy of the RFX.');
           return false;
           }
}
 
The script is working in the main form but it is giving me the error on the main RITM , whenever I click on the ""Cancel Request"
 
Error : 
 
PoojaKhatri_0-1715866466672.png

 

 

How can I fix this issue ?

5 REPLIES 5

dgarad
Giga Sage

Hi @Pooja Khatri 

Please take a look at the link below.

https://www.servicenow.com/community/developer-blog/verify-mandatory-attachments-count-on-catalog-it...

If my answer finds you well, helpful, and related to the question asked. Please mark it as correct and helpful.

Thanks
dgarad

Hi @dgarad - I have also used this.document.getelementsbyName in the same way as mentioned in the link to the article but its still not working .

 

How can I fix it ?

Harsh Vardhan
Giga Patron

@Pooja Khatri  you have written this script on catalog client script or client script ? I am assuming this is catalog client script, can you confirm , if you have unchecked the "Applies on Requested Items" checkbox  ? this way catalog client script wont be trigger on RITM .

 

Thanks,

Harsh

Hi @Harsh Vardhan - this is a catalog client script , the checkbox of Applies on Requested Items is already unchecked but still it is giving me the error on the RITM end .

 

 

How can I fix it ?