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

sndangibbard
Mega Guru

Jacob just to confirm - you have a variable on your catalog item with a matching name 'users_country' and you can see the value of users_country from the order guide being passed to the item?


Dan,



That is correct.


sndangibbard
Mega Guru

I was seeing the same undefined error as you Jacob!! Turns out was a silly mistake on my part


- Variables on my Order Guide and Items were both named 'user_country'


- In my Script I was trying to access them with 'users_country'



When I resolved that issue I was able to access the variable from my Workflow



One other thing to check is that your Workflow needs to be running on the sc_req_item table



Finally, to confirm this is what my script in the workflow looks like



var itemVariable = current.variables.user_country;


var itemValue = itemVariable.toString();




current.description=itemValue;


gs.log('from WF: ' + itemValue);


Dan,



Thank you for the response but it's still not working 😕



Let me break this way down so I'm not missing something silly.



1. I have an Order Guide that utilizes a few 'rule base' items.


2. On the main form of the order guide, the 'describe needs' section, there is a variable in a variable set named 'users_country' with a select box of 3 variables.


3. On the 'rule base' items there is 1 that will always get created and it too has a variable 'users_country' with a select box of 3 variables.


4. in the workflow I have your script above and it undefined