Attachment mandatory script in UI policy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2021 10:54 PM
Hi Techies,
I need help on coding part.....
i need script for attachment mandatory through UI Policy for my custom application when user raise a ticket for servicenow Quebec release.
Thanks in advance.....!
Regards,
Balaji
- Labels:
-
Change Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2021 11:37 PM
Hello
Please go through below article
https://community.servicenow.com/community?id=community_article&sys_id=0f0c5290dbe7f380d82ffb24399619f5
Please mark correct/helpful if you get expected solution
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2021 11:55 PM
Chetan,
Is it possible through UI Policy?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2021 12:05 AM
I don't think UI Policy would be best approach
but you can achieve this by business rule (Before Insert)
(function executeRule(current, previous /*null when async*/) {
if(current.hasAttachments()){
current.setValue("u_has_attachment","true");
gs.addInfoMessage("Attachment Present");
}
else if(!current.hasAttachments()) {
current.setValue("u_has_attachment","false");
gs.addInfoMessage("Attachment Absent");
}
}
Kindly Mark Correct/Helpful if you get expected response
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2021 12:13 AM
I don't think UI Policy would be best approach
but you can achieve this by business rule (Before Insert)
(function executeRule(current, previous /*null when async*/) {
if(current.hasAttachments()){
current.setValue("u_has_attachment","true");
gs.addInfoMessage("Attachment Present");
}
else if(!current.hasAttachments()) {
gs.addInfoMessage("Attachment Absent");
current.setAbortAction(true);
}
}
So, If user attached Attachment then only record will get insert otherwise will abort action
Kindly Mark Correct/Helpful if you get expected response
Thanks