- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2018 10:40 AM
Hi Team,
I have an implementation in which we disabled the shopping cart from the service catalog, therefore, for each REQ we have only one RITM, we now have a requirement to copy all the comments and work notes from the request to its related RITM and the related Catalog tasks, in order to improve the interaction between end users who interact in the REQ and fulfiller users who interact in the RITM. Has any of you guys worked in something like this?
Any help would be greatly appreciated.
Thank you.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2018 12:04 PM
HI,
i assume that you want to copy the comments from REQ to RITM and then RITM to SCTASK as soon as comments are inserted on REQ.
IF so then use after update BR on REQ and condition will be comments change
See below:
Condition : current.comments.changes() || current.work_notes.changes()
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('sc_req_item');
gr.addQuery('request',current.sys_id);
gr.query();
while(gr.next()){
gr.comments = current.comments;
gr.work_notes = current.work_notes;
gr.update();
var tsk = new GlideRecord('sc_task');
tsk.addQuery('request_item',gr.sys_id);
tsk.query();
while(tsk.next()){
tsk.comments = current.comments;
tsk.work_notes = current.work_notes;
tsk.update();
}
}
})(current, previous);
Thanks,
Ashutosh Munot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2018 01:20 PM
Every other field values are copied with After BR, why not Journal fields any idea?
Thanks Before BR worked.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2018 01:37 PM
HI,
Use current.u_comments.getJournalEntry(1));
IT will copy latest comments
Thanks,
Ashutosh Munot
Do mark answer as correct or Helpful

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2018 01:39 PM
Check this:
https://community.servicenow.com/community?id=community_question&sys_id=9a5f72a9db58dbc01dcaf3231f96198e
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2018 01:47 PM
Now i have an another query, consider Parent Ticket (REQ) has two related Requested_item (RITM),
now if you need to update parent from the child, how do you query in GlideRecord.
can your provide your thoughts on this?
eg:
var gr = new GlideRecord ("sc_req_item");
gr.addQuery("request",current.sys_id); --------> this part i'm struck coz we have two values and i dont know the
RITM field values coz it is in related list in Parent table, to pass an array also i need to know values of RITM in
parent ticket.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2018 01:47 PM
Now i have an another query, consider Parent Ticket (REQ) has two related Requested_item (RITM),
now if you need to update parent from the child, how do you query in GlideRecord.
can your provide your thoughts on this?
eg:
var gr = new GlideRecord ("sc_req_item");
gr.addQuery("request",current.sys_id); --------> this part i'm struck coz we have two values and i dont know the
RITM field values coz it is in related list in Parent table, to pass an array also i need to know values of RITM in
parent ticket.