Populating the RITM Category with Catalog task category.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2020 09:03 PM
Populating the RITM Category with Catalog task category.
I am looking to see if there is a possibility to populate the Category on the RITM with the Category on the Catalog task.
These are 2 independent fields and we did not have the requirements initially to have category on the RITM level and now the Category on RITM is important requirement.
Any help is appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2020 09:30 PM
Yes you can do this.
I am simply eyeballing the script here:
var grItem = new GlideRecord('sc_req_item');
grItem.addQuery('sys_id',current.parent);
grItem.setLimit(1);
grItem.query();
if(grItem.next())
{
grItem.u_category = current.u_category;
grItem.update();
}
The above script will work for any newly created record when put in business rule.
If you need to update old records:
var grTask = new GlideRecord('sc_task');
grTask.addNotNullQuery('u_category);
grTask.query();
while(grTask.next())
{
var grItem = new GlideRecord('sc_req_item');
grItem.addQuery('sys_id',grTask.parent);
grItem.setLimit(1);
grItem.query();
if(grItem.next())
{
grItem.u_category = grTask.u_category;
grItem.update();
}
}
Please verify the script once before running for all the records.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2020 10:02 PM
Hi Kirthi,
Please refer below link, from that you can understand the proper solution.
you can use this for your examination also.
If you think that my answer help you to solved issue please marked correct or helpful
Vanashree Kubal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2020 10:22 PM
Hi Kirthi,
You can create an after Insert business rule on catalog task. Where you will populate the category for RITM until it is empty. Suppose there are multiple ctask on the RITM then it should not overwrite the category again and agian.
Script will be:
var item = new GlideRecord('sc_req_item');
item.addQuery('sys_id',current.<backend value of request item field>);
item.addQuery('u_category',''); //enter in the loop only if category is empty
item.query();
if(item.next())
{
item.u_category=current.u_category
item.update();
}
Please mark my answer correct and helpful if it resolved the query and only helpful if it helped you at all.
Thanks,
Mohit Kaushik
Mohit Kaushik
ServiceNow MVP (2023-2025)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2020 10:17 AM
I tried the above 2 scripts and for some reason it did not update the Requested Items Category when I changed the Catalog item category.
Could you please let me know what am I doing wrong.
When I change the Catalog item category the Requested Item Category needs to be updated.