- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2015 05:46 AM
Has anyone got a script that will copy a variable from one RITM to another within the same REQ? I have a catalog item that is primary (PRF), then you can add several secondary items (Additional PRF). There's a section where the team leads assign an IT Engineer (it_engineer) to being the request to completion, but it occurred to me that the IT Engineer needs to be automatically added to the other RITMs. Any idea how we can accomplish this?
Thank you,
Amandah
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2015 06:36 AM
Hi Amandah,
Here is the updated code. Please go through it. In this case execute business rule only when the catalog item is primary catalog item. How we do that?
Yes this is simple all you need to do is under "When to run" select the filter condtition as item.name is the item name.
Script :
var gr = new GlideRecord('sc_req_item');
gr.addQuery('request', current.request);
gr.addQuery('cat_item_name', 'Additional PRF'); //Assuming Additional PRF is the catalog item name
gr.query();
while(gr.next())
{
gr.variables.it_engineer = current.variables.it_engineer;
gr.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2015 05:51 AM
Hi Amandah,
You can fetch the value of the catalog variables at the business rules as current.variables.caller; //Here caller is the name of the variable
You can GlideRecord the appropriate RITM and then push the value.
Please let me know if you have any questions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2015 06:17 AM
I have no experience with this type of business rule. Can you help me out at all with a basic code?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2015 06:22 AM
Hi Amandah,
Here you go.
var item = current.cat_item.name = 'Access'; //Replace Access with the exact item name you want to update
var gr = new GlideRecord('sc_req_item');
gr.addQuery('request', current.request);
gr.addQuery('cat_item_name', item);
gr.query();
while(gr.next())
{
gr.variables.caller = current.variables.stat; //Here replace caller with the target variable name and replace stat with the current variable name of which you want to copy.
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2015 06:27 AM
Hi Pradeep,
The variable names are the same (it_engineer) but the two catalog items are different. The variable will need to be pulled from the primary catalog item (PRF) and applied to all secondary items (Additional PRF) if any. I'm not sure that the code reflects that, or am I missing something?