Copy RITM Comments (Including Approval Comments) to SC Task with correct order and user information
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi All,
I have requirement where i need to copy all comment from an RITM - Including comments added during approvals - to the related SC Task. The goal is to ensure that all comments made before the approval are reflected on the SC Task once it is created.
I'm currently able to copy the comments successfully. However, I'm facing 2 issues:
1 - Comments Sequence/order on the SC Task does not match the original order from the RITM.
2- User - who made the comment is not getting copied correctly - it often shows the wrong user or the same name user for all comments.
Can anyone suggest the best way to maintain the correct the order and created by user when copying RITM comments to SC Task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
share your existing scripts and screenshots.
💡 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
3 weeks ago
I am trying this way to Insert Business rules for copy comment and fetch the created by user from sys journal table. Can you please look whether code is correct or suggest me any other alternative for it, which could work for it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
why not directly copy and why to use sys_journal_field?
💡 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
3 weeks ago
Hi there @Aman Sharma1
The best approach is to pull comments from the sys_journal_field table instead of relying on current comments directly, since that preserves both order and user data. You can query sys_journal_field for the RITM (element_id = current.sys_id) and sort by sys_created_on to maintain the right sequence.
like e this
var comments = new GlideRecord('sys_journal_field');
comments.addQuery('element_id', ritmSysId);
comments.addQuery('element', 'comments');
comments.orderBy('sys_created_on');
comments.query();
while (comments.next()) {
var note = new GlideRecord('sys_journal_field');
note.initialize();
note.name = 'sc_task';
note.element_id = taskSysId;
note.element = 'comments';
note.value = comments.value;
note.sys_created_by = comments.sys_created_by;
note.insert();
}
Kind Regards,
Mohamed Azarudeen Z
Developer @ KPMG
