- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2024 10:28 AM - edited ‎09-29-2024 01:03 AM
When we post comments on SCTASK, they get copied to the RITM Additional comments as,
2024-08-07 10:15:00 - Author Name (Additional Comments) fix is in progress
Is there a way to do this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2024 12:04 PM
Just wanted to make sure you weren't already doing something extra that I was about to undo. This should do that:
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item', current.request_item);
gr.query();
while (gr.next()) {
var comment = current.comments.getJournalEntry(-1);
var usrstrt = comment.indexOf(" - ");
var usrend = comment.indexOf(" (Additional");
var usrname = comment.substring(usrstrt+3, usrend); //isolate the user Name
var usrGr = new GlideRecord('sys_user');
if (usrGr.get('name', usrname)) {
var tz = '"' + usrGr.time_zone + '"';
comment = comment.replace(' - ', ' ' + tz + ' - '); //update the comment with "author's timezone"
}
gr.comments = comment;
gr.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-01-2024 12:31 PM
Hi @Brad Bowman
var comment = current.comments.getJournalEntry(1);
Using this is not appending the latest comment right after the existing detail, the latest comment is getting copied to the last,
Check the SS attached, the latest comment with 'C' appends at the last, this should be on top, right after 'Testing', can you share your thoughts on that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2024 03:32 AM
Since the comments are added one at a time, the existing Details changes with each update. After comment A is added the existing Details is Testing..... (Additional comments) A, so appending the next comment to the existing Details is adding it to the end. If you want the insertion point for the comment to be before a line that starts with a date, or maybe easier would be contains '(Additional comments)' you would have to incorporate this into desc in your script, splitting it into two different variables so that newDet = desc1 + comment + desc2.