- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2016 09:41 AM
Hi all,
I have a basic question. I have a catalog item and have created a variable called requested for(requested_for) on the catalog item. The value of this field needs to be passed to the requested for field(requested_for) on the request table (sc_request). How do I achieve this?
As you can see in the below screenshot, requested for value is Abel tutor in the catalog item form. I want this value to be passed to the request table instead of System Administrator. Please help.
Thanks & Regards,
Akriti
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2016 08:31 AM
Sorry, this script should be on sc_request table and change it from after to before business rule and put this script in there. You are good to go
var gr= new GlideRecord("sc_req_item");
gr.addQuery('request',current.getValue("sys_id"));
gr.addQuery("item.name","put your item name here");
gr.query();
if(gr.next()){
current.requested_for=gr.variables.requested_for;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2016 04:37 PM
There is default value set on requested for to the logged in user. In order to change the requested for value on request, you can create an after business rule on sc_req_item table
When: after insert
Conditions: Item is <slect your item>
Script:
var gr= new GlideRecord("sc_request");
gr.get(current.getValue("request"));
gr.requested_for=current.variables.requested_for;
gr.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2016 08:15 PM
Thank a lot Abhinay. The business rule is able to populate the correct requested for value in both request and requested item form. The issue I am having now if that after submitting the order I get unique key violation message.
Also due to this, for some reason the due date in request gets wiped out but appears in requested item
There are some Catalog items that do not have the requested for variable. For those cases the requested for field on the request form and requested item form is empty. Can you please suggest how to go about this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2016 08:31 AM
Sorry, this script should be on sc_request table and change it from after to before business rule and put this script in there. You are good to go
var gr= new GlideRecord("sc_req_item");
gr.addQuery('request',current.getValue("sys_id"));
gr.addQuery("item.name","put your item name here");
gr.query();
if(gr.next()){
current.requested_for=gr.variables.requested_for;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2016 09:17 AM
Perfect!! Thank you very much Abhinay!