Set the "requested for" on an RITM from a variable

Mark Weitzel1
Mega Expert

I've seen this posted as a solution, but I can not get it to work. We allow someone to open a request on behalf of someone. The variable for that field on the catalog item is u_who_is_asking_for_this_to_be_completed.  I added a "run script" to the workflow right after the "begin". But the issue is, it is setting the "requested by" field of the RITM, not the Requested for field.

 

We are running San Diego. 

 

I am not sure what I am doing wrong. 

 

Any help is appreciated. The code from the script is:

 

 

var sr = new GlideRecord('sc_request');

if(sr.get(current.request)){ sr.setValue('requested_for',current.variables.u_who_is_asking_for_this_to_be_completed); 

sr.update();

}

1 ACCEPTED SOLUTION

Ashir Waheed
Kilo Sage
Kilo Sage

Hi @Mark Weitzel1 

 

Given script in workflow should work fine. but you can try the following code in your workflow script.

 

var sr = new GlideRecord('sc_request');
if (sr.get(current.request)) {
//sr.setValue('requested_for',current.variables.u_who_is_asking_for_this_to_be_completed);
sr.requested_for.setDisplayValue(current.variables.u_who_is_asking_for_this_to_be_completed);

sr.update();
}

 

1. You should also reverify the Column Name(backend) for Requested for on the Request.

2. Verify that there is no Client script or BR that is clearing the Requested for field for REQ.

 

Regards,

Ashir Waheed

View solution in original post

2 REPLIES 2

Ashir Waheed
Kilo Sage
Kilo Sage

Hi @Mark Weitzel1 

 

Given script in workflow should work fine. but you can try the following code in your workflow script.

 

var sr = new GlideRecord('sc_request');
if (sr.get(current.request)) {
//sr.setValue('requested_for',current.variables.u_who_is_asking_for_this_to_be_completed);
sr.requested_for.setDisplayValue(current.variables.u_who_is_asking_for_this_to_be_completed);

sr.update();
}

 

1. You should also reverify the Column Name(backend) for Requested for on the Request.

2. Verify that there is no Client script or BR that is clearing the Requested for field for REQ.

 

Regards,

Ashir Waheed

I found a BR that was causing the issue. Once I fixed that, I was able to use the script.

 

Thanks!