Pull results from a variable lookup select box?

SC10
Kilo Guru

I have a variable, called Variable1 that is a lookup select box, pulling from a table. The table contains entries with values of A, B, and C.

In my workflow, I have an If statement returning a Yes or No. I would like the If statement to result in Yes, if the client script's select box variable selects "A" or "B" as it's value. If "C" is chosen, it would result in a No.

I tried using the following script for the If in the workflow, but am getting GetDisplayValue not defined as an error:

answer = isSmart();

function isSmart(){
var check= getDisplayValue(Variable1);
if(check == "A" || "B"){
return 'yes';
}else{
return 'no';
}
}


Any help is greatly appreciated.

Thank you.

19 REPLIES 19

Ran another test, chose the "iPhone 5S" option this time around, and again it resulted in a No instead of a Yes. No faults.


Is your Lookup Select Box set up like the pic?

Remove the .getDisplayValue() from your IF statement they are causing an error so you are NOT getting your logs.


Very similar, but I don't have anything in the "lookup label field"

This is what the entire field is setup as (file attached)


Did you remove the .getDisplayValue() from your WF? What are your logs showing?
Feel free to contact me directly via my email and we can look together in your instance.


The following is set up and working on DEMO007:
https://demo007.service-now.com/com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=039c516237b1300054b6a3549dbe5dfc&sysparm_preview=true&sysparm_stack=no

answer = isSmart();

function isSmart(){
gs.log('Variable - '+current.variables.item);
var check = current.variables.item;
gs.log('Smart Phone - '+check);
if (check == 'iPhone 5S' || check == 'Apple iPhone 5C (Recommended Selection)') {
return 'yes';
}else{
return 'no';
}
}