- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 05:01 PM
Hello,
How to create a business rule that grab all the Catalog Tasks that belong to a RITM?
Here is what I have, but it did not work. Please provide suggestions. Thank you
HERE IS THE ENTIRE CODE:
When to run: after insert and update
(function executeRule(current, previous /*null when async*/ ) {
var grTasks = new GlideRecord('sc_task');
grTasks.addQuery('parent', current.sys_id);
grTasks.query();
while (grTasks.next()) {
//do something with the task record
grTasks.short_description = current.short_description;
grTasks.decription = current.decription;
grTasks.assignment_group = "Service Desk";
grTasks.cmdb_ci = "Software";
grTasks.update();
}
})(current, previous);
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 05:53 PM
I will make an assumption of what it it you are looking for. Every catalog task that gets created as part of one particular catalog item needs to be updated with the RITM's short description and description in the corresponding fields, (I hope I'm right?)
Ideally this needs to be done on the Workflow or the Flow designer that is tagged to the catalog item. It's far more easier to maintain that way. Anyway, if for some reason you really have to do it with a BR, then have the BR on Catalog Task table and run it before insert.
Here's your code:
(function executeRule(current, previous /*null when async*/ ) {
current.short_description = current.request_item.short_description;
current.description = current.request_item.description;
})(current, previous);
Also, this can be achieved without any code with a flow designer. Give it a try 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 05:53 PM
I will make an assumption of what it it you are looking for. Every catalog task that gets created as part of one particular catalog item needs to be updated with the RITM's short description and description in the corresponding fields, (I hope I'm right?)
Ideally this needs to be done on the Workflow or the Flow designer that is tagged to the catalog item. It's far more easier to maintain that way. Anyway, if for some reason you really have to do it with a BR, then have the BR on Catalog Task table and run it before insert.
Here's your code:
(function executeRule(current, previous /*null when async*/ ) {
current.short_description = current.request_item.short_description;
current.description = current.request_item.description;
})(current, previous);
Also, this can be achieved without any code with a flow designer. Give it a try 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 08:14 PM
Thank you so much for helping AnirudhKumar!
I learned how to do it in flow designer, but I don't understand how to do it in Business Rule.
Your revised code works really well. Could you please show me the script to run only for 1 catalog item. I need to learn it in Condition and in filter condition.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2022 07:39 AM
Awesome!
To add the logic in the Condition field, this is the code:
current.request_item.item == '<<sysid of your item>>'
(we are simply dot walking to the related RITM record through the request_item field on the catalog task form and then accessing the item field on the RITM form which holds the catalog item sysid)
To add the logic on the filter, here's how you'd do:
1. In the filter, search for Request item and select Request item
2. Now scroll to the bottom of the filter and select Show Related Fields
3. Again search in the filter for Request item and select Request Item -> Requested Item fields
4. Again search in the filter for Item and select Item
5. Select your item from the reference in the 3rd box.
I took a video of the process, but unable to attach it here. Let me know if you got it from the description
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2022 09:09 AM
Hello AnirudhKumar,
I understood it clearly. Thank you so much for your time and effort!