- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2017 01:26 PM
I have the following IF Activity script in Workflow (global table). Variables are held in a custom Import table. If I just evaluate the companyCode variable, the script works. When I add the jobCode variable values the script does not evaluate correctly. I want to return NO if the companyCode matches, but the jobCode does not. Is there some other way to script this?
answer = ifScript();
function ifScript(){
var companyCode = current.variables.company_code;
var jobCode = current.variables.job_code;
if(companyCode == 'SJC' || companyCode == 'SHE' && (jobCode != '2000' || jobCode != '2019' || jobCode != '2057' || jobCode != '2064' || jobCode != '2086' || jobCode != '2088' || jobCode != '2130' || jobCode != '2208')){
return 'yes';
} else {
return 'no';
}
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2017 03:52 PM
Mike,
let me clarify the requirement, if companycode is either SJC or SHE and jobcode is not one of 2000,2019,2057,2064,2086,2088,2130,2208 then you need to return yes. am i right?
so shouldn't the if statement be:
if((companyCode == 'SJC' || companyCode == 'SHE') && jobCode != '2000' && jobCode != '2019' && jobCode != '2057' && jobCode != '2064' && jobCode != '2086' && jobCode != '2088' && jobCode != '2130' && jobCode != '2208')

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2017 01:41 PM
What is the variable type of job_code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2017 01:45 PM
job_code is a string variable from the import table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2017 01:47 PM
your if statement is filled with 'ORs'.
If you say if a number is not 2 or a number is not 3 - it will always return true.
Negation and or do not play well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2017 03:52 PM
Mike,
let me clarify the requirement, if companycode is either SJC or SHE and jobcode is not one of 2000,2019,2057,2064,2086,2088,2130,2208 then you need to return yes. am i right?
so shouldn't the if statement be:
if((companyCode == 'SJC' || companyCode == 'SHE') && jobCode != '2000' && jobCode != '2019' && jobCode != '2057' && jobCode != '2064' && jobCode != '2086' && jobCode != '2088' && jobCode != '2130' && jobCode != '2208')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2017 06:03 PM
Your clarification is correct Ajit and the script works. Thank you for the reply. I will mark your answer correct. I originally tried that same script using the OR operator instead of the AND. I see the errors of my ways now and it seems I have made a mountain out of a mole hill. Thank you all for your assistance.