How to set "Requested for" on Request and Requested Item

Kyle Krick
Giga Contributor

Is it possible to set the field "Requested for" on a catalog item's Request and Requested item records? I have many catalog item to create where the Requested for is not supposed to be the person who actually filled out the form. However, Requests and Requested Items default the "Requested for" to the person filling out the form.

I have defined a "Requested for" variable set that asks for a user record who the catalog item is actually being submitted for, because only a few people have access to these forms, so they submit it on behalf of other users.

I want to know the best way to set the Request and Requested Items "Requested for" to match what the user enters into the question in my variable set. Can it be done with a catalog client script? Could it be done on a variable set? Ideally I'd like to do it on the variable set so that every catalog item that uses my variable set picks up this behavior, rather than having to replicate something on every single catalog item.

1 ACCEPTED SOLUTION
6 REPLIES 6

Jaspal Singh
Mega Patron
Mega Patron

Hi Kyle,

 

There are multiple options.

1. If you have workflow for catalog items then you can add a Run script activity immediate next to the Begin with line as

current.request.requested_for=current.variables.variable_name; //replace variable_name with requestedfor variable name.

But this then will have to be done for all workflows that you have on different catalog items.

 

2. Create a Business rule that updates the same & will update irrespective of catalog item (one time activity).

You can follow link for the code.

Chander Bhusha1
Tera Guru

Hi Kyle Krick,

The requestor for field on requested item is the field inherited from the request table.

So for update the best way is to use the Run script in the start of the workflow  after begin activity for that catalog item which will copy the variables to the request requester for.

The script should be placed in the runscript of the catalog item workflow:

var sr = new GlideRecord('sc_request');

if(sr.get(current.request)){

sr.setValue('requested_for',current.variables.requestor_for); //Requestor for variable

sr.update();

}

Once updated the requested for will appear in the ritm as well in the request.

 

 

The client script is not used to update the requested for. 

 

 

Please mark answer to correct and helpful.

Thank,

CB

 

That first link is exactly what I was looking for! I was thinking to business rule, but not necessarily every request will have the requested for variable set. That first link's solution checks first to see if the request has a variable for requested for, so I won't be breaking other catalog items that don't use my variable set. Perfect! Thanks.