
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2016 07:14 AM
I'm having a quandary trying to see why this is not working, I'd like to think it is a fairly simple thing and I have been looking at screens too long this week!
answer = ifScript();
//
var location = current.variables.requested_for.location.getDisplayValue();
(sample value of location is UKBAS1 -blah blah blah)
function ifScript() {
if (location.toString().indexOf('UKBAS1') >= 0) {
return 'yes';
}
return 'no';
}
I've tried == 0, != -1 as well. Just looking to test for a match if the string contains UKBAS1
Has to be something simple here
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2016 08:23 AM
Hello Derek,
I am able to do thing like this. The only difference between my code and yours is where I declare my variables. I declair them in the fucation not before it.
answer = ifScript();
//
function ifScript() {
var location = current.variables.requested_for.location.getDisplayValue();
if (location.toString().indexOf('UKBAS1') >= 0) {
return 'yes';
}
return 'no';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2016 08:29 AM
Oh wow, Brian nailed it. I missed that too. It's simply an ordering issue. answer = ifScript(); gets run and doesn't care about var location:
answer = ifScript();
var location = current.variables.requested_for.location.getDisplayValue();
should be:
var location = current.variables.requested_for.location.getDisplayValue();
answer = ifScript();
or like Brian said, declare var location inside the ifScript() function if it doesn't need to be used outside of that function...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2016 08:37 AM
Thank you gentlemen!
I have been working on this 1 aspect for 3 hours. Time for drinks! Open up a tab on me!
Derek