Need help on adding additional comment via script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi,
I have written this BR which is before on sys_attachment table, restricting user from deleting an attachment once the request is submitted, I want to updated an additional comment which is not happening at this moment
(function executeRule(current, previous /*null when async*/ ) {
var parentTable = current.getValue('table_name');
var parentSysId = current.getValue('table_sys_id');
// Only block deletion on RITMs
if (parentTable == 'sc_req_item') {
var grRequest = new GlideRecord('sc_req_item');
if (grRequest.get(parentSysId)) {
var catalog = grRequest.getValue('cat_item');
if (catalog == 'sys_id of item') {
gs.addErrorMessage("You are not allowed to delete attachments for this item.");
grRequest.comments = "test";
grRequest.update();
current.setAbortAction(true);
}
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hello ,
Try below Code and please explain more about how you would like to update additional commments ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
since the BR is on sys_attachment your user won't see the message
but yes you can update the comments
try this
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi @Ankur Bawiskar
I tried this but it is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
did you debug and see if it's going inside that IF?
if you get the color log which I added then it should update the comments field on RITM
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
