Check variable value in a If condition on the request table workflow

mohammedunwala
Giga Contributor

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

5 REPLIES 5

Oh yeah absolutely, you should be able to access the request number in the workflow and replace in the script .


I did this script as background script, so i left that as a place holder for you to replace with current.number.



so this is how it should be, i haven't tested this in a workflow . let me know if you run into any issues



var gr = new GlideRecord('sc_req_item');


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


gr.query();


while(gr.next()){


if( gr.variables.v_manager_approval == "No" ){


<do something>


}


}