IF statement always returning NO

Savitha4
Tera Contributor

I am using an IF activity in the workflow editor to check the variable's value if it is Yes or No. The script is returning No always. I have attached the script for reference.

answer = ifScript();
function ifScript() {
var getVariable = current.variables.contact_center_supervisor_access.getDisplayValue().toString();
gs.log("value is" + getVariable);
if (getVariable  == "Yes")
{
gs.log("test");
       return 'Yes';
}
else
       return 'No'; 
}

The script is printing correct values in the logs, ie the value of the variable is correct and when the IF condition is evaluated to be true the control is entering the loop but the final answer returned is NO. 

Thanks in advance.
1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron
Mega Patron

Hi Savitha,

Try below

answer = ifScript();
function ifScript() {
var getVariable = current.variables.contact_center_supervisor_access.getDisplayValue().toString();
gs.log("value is" + getVariable);
if (getVariable  == "Yes")
{
gs.log("test");
       return 'yes';
}
else{
       return 'no'; 
}
}

View solution in original post

5 REPLIES 5

manjusha_
Kilo Sage

@Savitha4 

var getVariable = current.variables.contact_center_supervisor_access.getDisplayValue();//getDisplayValue method  returns string value so no need to use toString() again
 
Also check getVariable is having start letter as capital or small and use it in your if else loop
 
Thanks,
Manjusha Bangale