- 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 12:24 PM
You are welcome - happy to help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2024 10:26 AM - edited ‎09-30-2024 01:34 PM
Another small help needed
In a scenario I am trying to copy comments from RITM to a HTML Field on SCTASK, First comment gets copied perfectly, when adding second comment and checking the HTM field on SCTASK, It shows three comments two with TZ and one without TZ (SS attached)
Please review and let me know where I am making the mistake in script,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2024 12:25 PM
What are the testing steps. Details contains 'Testing' then one comment is added by clicking the Post button, or Saving the form, or you're testing both methods? What table is your Business Rule running on?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2024 12:37 PM - edited ‎09-30-2024 12:44 PM
Comment is added on RITM using the Post button,
The BR is running on sc_req_item
@Brad Bowman
Testing steps:
1. Add a comment on RITM either through post button or updating the form.
2. The comment gets copied to Details on SCTASK as expected.
3. Now add another comment on RITM, the second comment gets added to the SCTASK Detail field and with that the first comment without Time Zone information also gets displayed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2024 01:01 PM
That script shouldn't be doing anything as there is not a field on the sc_req_item table named request_item. Since this is running on the sc_req_item table, your addQuery line should be
gr.addQuery('request_item', current.sys_id);
You must have already discovered that, or it wouldn't be updating any sc_task records. Just be aware that this will update the Details field on all Catalog Tasks that exist for this RITM.
Aside from all that, getJournalEntry(-1) translates to "retrieve all of the journal entries" when you really want just the most recent since this is running every time the comment changes, so use
var comment = current.comments.getJournalEntry(1);