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.

In client script restrict user submitting the form without attachment

harishdasari
Tera Guru

Hello everyone,

Can I know in incident form using client script, how to restrict the user submitting the form without uploading a attachment ?

3 REPLIES 3

Mike Allen
Mega Sage

In business rule, you can use the following:


http://wiki.servicenow.com/index.php?title=GlideRecord#hasAttachments&gsc.tab=0



along with an abort.



So, taking that, you can create a Ajax script include that calls this and returns true or false.   Then, have an onSubmit that uses GlideAjax, and if it returns false, stop the submit.


Chuck Tomasi
Tera Patron

A quick search for "Mandatory attachment" on the community brings up several hits depending on your scenario. Take your pick.


bala_sn
Kilo Expert

Create a Business rule, instead.



Name: Don't create incident without attachment


When: Before Insert


Advanced: True


Condition: !current.hasAttachments()


Script:


(function executeRule(current, previous /*null when async*/) {


    current.setAbortAction(true);


})(current, previous);