- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2016 03:29 PM
I have a business rule on the "sc_req_item" table that is fired when any change is made. Within that business rule, I'd like to access the catalog task(s) that sit beneath it (below the RITM). Does anyone know how I would go about doing that from the business rule that fires on the sc_req_item?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2016 03:42 PM
Hi Stephen,
To grab all the Catalog Tasks that belong to a RITM, you can use the following in a server-side script such as a business rule:
ex. BR on [sc_req_item]
var grTasks = new GlideRecord('sc_task');
grTasks.addQuery('parent', current.sys_id);
grTasks.query();
while(grTasks.next()){
//do something with the task record
grTasks.update();
}
Keep in mind that current is referring to your Requested Item.
Thanks,
-Brian

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2016 03:42 PM
Hi Stephen,
To grab all the Catalog Tasks that belong to a RITM, you can use the following in a server-side script such as a business rule:
ex. BR on [sc_req_item]
var grTasks = new GlideRecord('sc_task');
grTasks.addQuery('parent', current.sys_id);
grTasks.query();
while(grTasks.next()){
//do something with the task record
grTasks.update();
}
Keep in mind that current is referring to your Requested Item.
Thanks,
-Brian

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2016 04:44 PM
By the way, forgot to mention... in the context of 'When' to run this Business Rule, you would probably want it running as either an After rule, since it is acting upon a different table and not making changes to the current record.
And as Abhinay commented, if you describe better what it is you are trying to accomplish, we can probably give you more detailed guidance.
-Brian

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2016 04:32 PM
What are you trying to do here?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2016 04:33 PM
Brian is correct. It's a basic GlideRecord. One of the most common scripts you'll ever write in ServiceNow. Read about it here: GlideRecord - ServiceNow Wiki