Check variable value in a If condition on the request table workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 08:49 AM
Hi,
I have a Yes/No variable 'v_manager_approval' which is a part of a variable set used across all of my catalog items. I have Requested For Manager Approval on Request level. Requirement is whenever the value on my variable is Yes it should go for approval if the value on 'v_manager_approval' variable is No it should skip the approval.
To accomplish this: I have an if condition in the workflow and using the following script:
var cat = new GlideRecord('sc_req_item');
cat.addQuery('variables', current.variables.v_manager_approval);
cat.query();
while (cat.next()){
if (cat =='No') {
return 'yes';
}
}
return 'no';
Unfortunately, the script is not working and is currently sending all catalog items for manager approval. What am i doing wrong?
Any help would be appreciated.
Thanks,
Mohammed
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 08:56 AM
Hi Mohammed,
Assuming the workflow is running on the request (sc_req_item) table, i don't think you need the Gliderecord, you should be able to do a compare with current.variables alone.
try this way
if (current.variables.v_manager_approval == 'no')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 08:59 AM
Hi Karthik,
The workflow is running on sc_request table. That means i need a glide record, right?
Can you help me out with the script?
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 09:22 AM
Ah, i get. Try with the script below.
var gr = new GlideRecord('sc_req_item');
gr.addQuery('request.number',<request number>);
gr.query();
while(gr.next()){
if( gr.variables.v_manager_approval == "No" ){
<do something>
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 09:55 AM
Why do I have to hardcode the request number? I want to keep it dynamic. Makes sense?
Thanks,
Mohammed