In client script restrict user submitting the form without attachment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2016 05:14 AM
Hello everyone,
Can I know in incident form using client script, how to restrict the user submitting the form without uploading a attachment ?
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2016 05:17 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2016 05:17 AM
A quick search for "Mandatory attachment" on the community brings up several hits depending on your scenario. Take your pick.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2016 05:22 AM
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);