Not able to use Order Guide Variable in Workflow

jacobpeterson
Mega Expert

Hello all,

I'm trying to use a Variable from an Order Guide in a workflow but having difficulties. I have

current.variables.users_country does not work.

Any help would be great!

1 ACCEPTED SOLUTION

If you're on the request table, then you're going to need to query the RITM table for request items with the request of current.   If all the items on the request will have that variable, then you can get the value from the first one (since it sounds like it will be identical across all items).



Something like the blurb below should grab that variable value while still running on the request table.



var user_country;


var gr=new GlideRecord('sc_req_item');


gr. addQuery('request', current);


gr.query();


if(gr.next()){


        user_country=gr.variables.user_country;


}


View solution in original post

7 REPLIES 7

I forgot to mention, the workflow is also running in the REQ not the RITM


If you're on the request table, then you're going to need to query the RITM table for request items with the request of current.   If all the items on the request will have that variable, then you can get the value from the first one (since it sounds like it will be identical across all items).



Something like the blurb below should grab that variable value while still running on the request table.



var user_country;


var gr=new GlideRecord('sc_req_item');


gr. addQuery('request', current);


gr.query();


if(gr.next()){


        user_country=gr.variables.user_country;


}


Dan/Ban thanks a bunch for the help!



This finally worked using:



workflow.scratchpad.country = '';


var gr = new GlideRecord('sc_req_item');


gr.addQuery('request', current.sys_id);


gr.query();


if(gr.next()){


      workflow.scratchpad.country = gr.variables.users_country;


}