- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I need to copy my additional comment from RITM to sc_task . But my sc_task contain group type "Restriction" Only user part of sc_task can able to see the sc_task. So, comment is copying properly.
I tried creating an event + BR + script action but it not working
BR: (After - update)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
in after update BR on RITM, no script action required
BR Condition: Comments Changes
(function executeRule(current, previous /*null when async*/ ) {
var sctask = new GlideRecord('sc_task');
sctask.addQuery('request_item', current.sys_id);
sctask.setWorkflow(false); // disables query BR and allows script to query that record
sctask.query();
while (sctask.next()) {
var comments = current.comments.getJournalEntry(1).match(/\n.+/gm).join("\n");
comments = comments.replace('\n', '');
sctask.comments = comments;
sctask.update();
}
})(current, previous);
💡 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 || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi..
Not quite—this will run, but it has a couple of mistakes that will break or behave incorrectly. You’re updating the wrong variable (sc_task.update() instead of grSCTask.update()), and directly assigning grSCTask.comments = ritmComment won’t reliably write to a journal field. Also, you should only trigger when the comment actually changes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hey
The problem is that in your Script Action you’re using current.sys_id, but current doesn’t exist there, so your query never finds any sc_task records and always goes to the “not found” log; to fix it, pass the RITM sys_id in the event (e.g., gs.eventQueue("ritm.comment.add", current, latestComment, current.sys_id);) and then use event.parm2 in the Script Action to query sc_task, which will allow the comment to copy correctly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
@TharaS657398130 can you send me sample how to call the event.aprm2 in the script action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
if you are restricting sc_task using Query BR then update this line
💡 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 || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
In script action?
