Requested_For Variables Request/Requested Item

JamesEcoStratus
Mega Guru

Requested_For Variables Request/Requested Item

HI Community!

Need some advise and a little help. In Fuji release I am trying to sync the REQ & RITM requested_for variable from a variable set and for some reason its not working - Any ideas, Help is appreciated.

Issue: The 'requested for' on both the request and the requested item, does not populate from the variable set "requested for". Please see below.

Requirement: requested for on both the item and request level to populate from the variable set, as many people open on behalf of other users.

Screen Shot

Screen Shot 2016-04-19 at 5.20.44 PM.png

Below is a mock version of proposed script - just not sure if this is best approach?  

var req = new GlideRecord('sc_request');

req.addQuery('sys_id', current.request); // find the REQ record

req.query();

// if REQ record found then set value

if (req.next()){

    req.requested_for = current.variables.requested_for;

    req.update();

}

Thanks for any help.

James

1 ACCEPTED SOLUTION

JamesEcoStratus
Mega Guru

Hey Community.



UPDATE - SOLVED



I guess all I needed was some sleep!!



Here is what will do the trick.



1. Open the workflow attached to request


2. Check it Out


3. Add the script below in the workflow after "Begin" as a run script activity.


4. NOTE - The requested_for field is actually on the sc_request not the sc_req_item.



var req = new GlideRecord('sc_request');


req.addQuery('sys_id', current.request); // find the REQ record


req.query();


// if REQ record found then set value


if (req.next()){


    req.requested_for = current.variables.requested_for;


    req.update();



Regards,



James


View solution in original post

5 REPLIES 5

JamesEcoStratus
Mega Guru

Hey Community.



UPDATE - SOLVED



I guess all I needed was some sleep!!



Here is what will do the trick.



1. Open the workflow attached to request


2. Check it Out


3. Add the script below in the workflow after "Begin" as a run script activity.


4. NOTE - The requested_for field is actually on the sc_request not the sc_req_item.



var req = new GlideRecord('sc_request');


req.addQuery('sys_id', current.request); // find the REQ record


req.query();


// if REQ record found then set value


if (req.next()){


    req.requested_for = current.variables.requested_for;


    req.update();



Regards,



James


Very helpful!

ServJen
Kilo Contributor

You had the exact same problem as myself, and your solution worked!

Excellent! Happy it helped!