Make Attachment mandatory in WS form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi ,
Make the attachment mandatory in the UI action button , when the button click , check attachment if there is no attachment then make attachment mandatory to submit that form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @armanoj ,
add these lines to your ui action
if(current.hasAttachments() != true){
gs.addInfoMessage("PLease add an attachment");
current.setAbortAction(true);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
which UI button? where native or workspace or this is catalog form?
share some screenshots
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @armanoj
You can meet this requirement by using a combination of a UI Action + a Business Rule.
Step 1: Add the following script to your specific UI Action . Sample step is on Close Ui Action.
if (!g_form.hasAttachments()) {
alert("Please attach a file before closing the task.");
return false;
} else {
g_form.setValue('state', 'closed'); // Modify the state value as per your requitement
g_form.save();
}
})();
Step 2: Configure BR
- When: Before
- Insert: true
- Update: true
- Condition: State changes to Closed
In the Script section, include:
if (current.state == 'closed' && !current.hasAttachments()) {
gs.addErrorMessage('Please attach a file before closing the task.');
current.setAbortAction(true);
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
@Ankur Bawiskar @Rakesh_M ,
onclick () button action
