- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2023 11:39 AM
Hello,
I am looking for a way to pull the watch list from a new RITM into the SCTask record. I have set up a business rule to run after the Watch List changes, but am having issues getting my code to work. I would appreciate any help on getting this to work from you smart people. Thank you!
(function() {
//get the gliderecord for the parent request
var task = new GlideRecord('sc_task');
if (task.get(current.catalog_task)) {
task.watch_list = current.watch_list;
task.update();
}
})();
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2023 11:54 AM
Hi Josh,
Since this BR is running on the sc_req_item table, 'current' refers to the RITM record that is being changed. There is not a field on the sc_req_item table named catalog_task, so that's where your script is failing. Something like this should work, copying the watch_list to ALL Catalog tasks that exist at the time of the update:
var task = new GlideRecord('sc_task');
task.addQuery('parent', current.sys_id);
task.query();
while (task.next()) {
task.watch_list = current.watch_list;
task.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2023 03:31 PM
You are welcome!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2023 11:58 AM
Hi @Josh Hines ,
Can u try the below code .
var gd = new GlideRecord('sc_task');
gd.addQuery('request_item',current.sys_id)
gd.query();
while(gd.next()){
gd.watch_list = current.watch_list;
gd.update();
}
Mark my answer helpful & accepted if it helps you resolve your query.
Thanks,
Danish