- 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
‎09-27-2024 11:03 AM
Hi Charles,
I'm having a think on something that might just work. Can you post the script using the insert code icon </> of the Business Rule that is copying the comment to the RITM?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2024 11:23 AM - edited ‎09-27-2024 11:24 AM
Hi @Brad Bowman
Here is the script,
(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);
gr.comments = comment;
gr.update();
}
})(current, previous);
- 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
‎09-27-2024 12:13 PM
Thanks @Brad Bowman - It worked