multiple condition not working in workflow If condition

caffry
Kilo Guru

i used the below script in the if condition..

answer = ifScript();

function ifScript() {

var country = current.variables.country;

       if (country!='10'||country!='3'||country!='4'||country!='15'||country!='16'||country!='21') 
	   {
gs.log(country.getDisplayValue());
     return 'yes';

}


return 'no';


       }

when i give country value as 3 in the catlog variable it returnzz 'yes'

can i know why?

in gs.log the value is passing correctly.

 

1 ACCEPTED SOLUTION

Deepak Ingale1
Mega Sage

Hello,

You can try below code

 

Note: Please mark reply as correct if it answers your question.

answer = ifScript();

function ifScript() {

    var country = current.variables.country;
    var countries = [
        '10',
        '3',
        '4',
        '15',
        '16',
        '21'
    ];
    var aru = new ArrayUtil();

    if (aru.indexOf(country) == -1) {
        gs.log(country.getDisplayValue());
        return 'yes';
    }

    return 'no';

}

View solution in original post

6 REPLIES 6

Alikutty A
Tera Sage

Hello Can you change this to use &&

if (country!='10'&&country!='3'&&country!='4'&&country!='15'&&country!='16'&&country!='21')

{ gs.log(country.getDisplayValue()); return 'yes'; }

The other conditions are passing, hence it is entering the loop always. eg country !=10 is passed

 

siva_
Giga Guru

try using .toString() and let me know if you are able to make it up.

 

Thanks,

Siva

siva_
Giga Guru

yes i missed it you should use && 🙂