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

vinothkumar
Tera Guru

Since you have given OR condition, suppose if you have given value as 3 also, because of OR condition, it will give value as Yes only, because other condition are passing right..example..Value is not 10 like that.

 

OR may not work correctly for your requirement.

 

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

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';

}