Copy additional comments from requested item item to all catalog tasks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2021 12:03 AM
Hi,
I have a requirement where i have to copy the additional comments from requested item to all the catalog tasks.Once the item is approved all the comments after the RITM is approved, should be copied to each and every catalog tasks.
How can i achieve that?
Thanks.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2021 02:58 AM
Kindly use the code (edited one) that i have provided above.
Whenever a new comment is added after approval it will fetch that and add into the associated catalog tasks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2021 03:22 AM
Hi,
the issue is still the same even after using the above script.
If i use getJournalEntry(-1) it copies all the comments and it gets repeated.
If i use getJournalEntry(), it works fine for one task but if the RITM has multiple tasks then it only copy current comments not the previous ones before that tak was created.
i want all the comments to get copied to every task and the duplicate comments should not occur.
i have attached the screenshot of how the same comment is copied after using getJournalEntry(-1).
Please help!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2021 03:32 AM
Hello SK,
If you have written a BR on ritm table with following conditions
After Update
Approval is approved
AND
additional comments changes
Then it would mean that your Br will run when every new comment that is added after ritm is approved.
And in your script, you can use the below code which will add that latest comment (that was added after approval) to all your catalog tasks.
//fetch your catalog tasks
var gr = new GlideRecord("sc_task");
gr.addQuery("request_item",current.sys_id);
gr.query();
while(gr.next()) {
//fetch latest ritm comments liek this
var comments = current.comments.getJournalEntry(1);
gr.comments = comments.toString();
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2021 03:41 AM
yup, it is working fine for first task but for the next task it is only copying the current comment not all the comments that were updated onRITM before the first task gets closed. i want to copy each comment on catalog task that are not made when it was open.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2021 04:04 AM
Okay.. so if your 2nd task is created much later the 1st task then you are not getting all comments in the 2nd task.
In that case, write another BR on catalog task
after insert
script
var gr = new GlideRecord("sysapproval_approver");
gr.addEncodedQuery("sysapproval="+current.request_item+"^state=approved");
gr.query();
if(gr.next()) {
//get approval date
var approval_date = new GlideDateTime(gr.getValue("sys_updated_on"));
var gr = new GlideRecord("sys_journal_field");
gr.addEncodedQuery("element=comments^element_id="+current.request_item+"^sys_created_on>==javascript:gs.dateGenerate('"+approval_date.getDate()+"','00:00:00')");
gr.query();
while(gr.next()) {
current.comments=gr.getValue("value");
current.update();
}
}
This will fetch all comments from RITM after approved and udpate in the catalog tasks during the creation of catalog task.
After this your 1st Br will take care of any new comments added.
Mark the comment as a correct answer and also helpful once worked.