- 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
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
Sure,
In your BR -
gs.eventQueue("ritm.comment.add", current, latestComment, current.sys_id);
In your script action -
(function executeAction(event) {
var ritmId = event.parm2; // this is the RITM sys_id
var comment = event.parm1; // this is the comment
var tasks = new GlideRecord("sc_task");
tasks.addQuery("request_item", ritmId);
tasks.query();
while (tasks.next()) {
tasks.comments.setJournalEntry(comment);
tasks.update();
}
})(event);
So in short: event.parm1 = comment, event.parm2 = RITM sys_id, and you just use event.parm2 like a normal variable in the Script Action.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I tried the same but still it not copying.
BR:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
did you try the approach I shared?
💡 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
Yes, it is copying not but not showing exact user you entered the comment.IT show as "system".
