- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2018 03:37 AM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2018 03:51 AM
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';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2018 03:40 AM
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'; }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2018 03:42 AM
The other conditions are passing, hence it is entering the loop always. eg country !=10 is passed

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2018 03:40 AM
try using .toString() and let me know if you are able to make it up.
Thanks,
Siva

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2018 03:41 AM
yes i missed it you should use && 🙂