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

Dhananjay Pawar
Kilo Sage

Hi,

I believe that functionality is already present.

Thanks,

Dhananjay.

Archana Dudhan1
Kilo Expert

Hi,

I agree with Dhananjay but still if you are not getting that functionality ,you can share the screenshot of after submit form so that we can help you out.

Thanks,

Archana D.

Hi Archana,

THis is the screen shot of Catalog item after you click on Try it

find_real_file.png

This is its corresponding request

find_real_file.png

 

I want Abel Tuter in the Requested for field of Request table.

 

 

Regards,

Indup

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