- 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:54 PM
HI,
We need to write BR on RITM as well.
But either have this process from REQ to RITM or from RITM to REQ.
IF we write BR on both for same purpose it might go into a loop.
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2018 02:55 PM
Thanks for your response,i really appreciate it.
Yes i got the logic, from your link which you shared, i could understand how to avoid the looping.
but my concern is if you do scripting in sc_request, how to know RITM.
for ex.
Parent to child:
(Working Part)
var gr = new GlideRecord ("sc_req_item"); // Child table
gr.addQuery("request",current.sys_id); // this where you will pass the sys_id and get the parent record.
gr.query();
now Child to Parent:
(Not working Part)
var gr = new GlideRecord ("sc_request"); // Parent table
gr.addQuery("request_item",current.sys_id); // can you provide the query here ("This doesnot work for me")
gr.query();
can you help me with this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2018 05:02 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2018 12:41 PM
Hi @vipinm We achieved this by having another set of business rules, one on each table,
On sc_req_item
(function executeRule(current, previous /*null when async*/) {
var sc = new GlideRecord('sc_request');
sc.addQuery('sys_id', current.request);
sc.query();
while(sc.next()) {
//sc.short_description = current.short_description;
//sc.description = current.description;
sc.work_notes = current.work_notes;
sc.comments = current.comments;
sc.update();
}
})(current, previous);
and on sc_task
(function executeRule(current, previous /*null when async*/) {
var sc = new GlideRecord('sc_req_item');
sc.addQuery('sys_id', current.request_item);
sc.query();
while(sc.next()) {
// sc.short_description = current.short_description;
// sc.description = current.description;
sc.work_notes = current.work_notes;
sc.comments = current.comments;
sc.update();
}
})(current, previous);
I hope this helps you.
Regards!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2018 12:51 PM
Thanks for sharing the logic even after closing this thread.
Actually got struck at getting the request_item field name.
now it is good and i understood the logic.