Map to Requested for field on Request table

Indup
Tera Expert

Hi guys,

I have created a catalog item. So once i submit the item, i want to populate Requested for field on Request with the User field in the catalog item. How can i do that? I mean how to map catalog item fields to its Request fields?

 

Regards,

Indup

1 ACCEPTED SOLUTION

Hi Indup,

There are two ways to do it. 

One is if you have a workflow then after the Begin acitivty add a Runscript acitvity and paste the code there:

ar req = new GlideRecord('sc_request');
req.addQuery('sys_id',current.request);
req.query();
if(req.next()){
req.requested_for = current.variables.user; //current.variables.user is to read the user name from catalog form. same like opend, you can pick other variable value.
req.update();
}

 

Second way:

Create a after insert BR and copy the code there:

business ruel -- when -- After

Insert - true

Conditoin : - Item is your catalog item

script:

ar req = new GlideRecord('sc_request');
req.addQuery('sys_id',current.request);
req.query();
if(req.next()){
req.requested_for = current.variables.user; //current.variables.user is to read the user name from catalog form. same like opend, you can pick other variable value.
req.update();
}

 

 Note: Replace the user with the user variable in your catalog item

 

Mark helpful and correct if it helps.

Thank,s

CB

View solution in original post

5 REPLIES 5

Thank you CB,

I am able to achieve it now. 

 

 

Regards,

Indup