
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 06:45 AM
Currently working on a Requirement - Where I have 8 Checkboxes, depending on the number of Checkboxes that get selected, I need the Workflow to take two different paths.
If 1 Checkbox is selected, path A
If 2 or more are selected, path B
Everything I am finding is OnSubmit, or OnChange Script, nothing with IfScripts and I am wondering if its possible.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 12:07 AM
You're not far off, but I would structure it a bit differently.
I presume you are running this in an if action within a workflow? If so, you do not have g_form available.
Try something like this:
answer = ifScript();
function ifScript() {
var fieldNames = ['field1', 'field2', 'field3', 'field4', 'field5', 'field6', 'field7', 'field8'];
var count = 0;
for (var i = 0; i < fieldNames.length; i++){
if (current.variables[fieldNames[i]] == true){
count++;
}
}
return count > 1; //false if 1, true if more than 1
}
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 02:08 AM - edited 02-09-2024 02:49 AM
Hi Mark,
I assumed you were talking about a catalog item, but I realize you didn't state that.
If it's for a regular record, you can use this script:
answer = ifScript();
function ifScript() {
var fieldNames = ['field1', 'field2', 'field3', 'field4', 'field5', 'field6', 'field7', 'field8'];
var count = 0;
for (var i = 0; i < fieldNames.length; i++){
if (current[fieldNames[i]] == true){
count++;
}
}
return count > 1; //false if 1, true if more than 1
}
If it's indeed for a requested item with variables, you can use this script (I used true/false instead of yes/no before)
answer = ifScript();
function ifScript() {
var fieldNames = ['field1', 'field2', 'field3', 'field4', 'field5', 'field6', 'field7', 'field8'];
var count = 0;
for (var i = 0; i < fieldNames.length; i++){
if (current.variables[fieldNames[i]] == 'Yes'){
count++;
}
}
return count > 1; //false if 1, true if more than 1
}
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 12:07 AM
You're not far off, but I would structure it a bit differently.
I presume you are running this in an if action within a workflow? If so, you do not have g_form available.
Try something like this:
answer = ifScript();
function ifScript() {
var fieldNames = ['field1', 'field2', 'field3', 'field4', 'field5', 'field6', 'field7', 'field8'];
var count = 0;
for (var i = 0; i < fieldNames.length; i++){
if (current.variables[fieldNames[i]] == true){
count++;
}
}
return count > 1; //false if 1, true if more than 1
}
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 10:59 AM
Thank you for your help Peter,
After testing this more, it will not return true or false.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 02:08 AM - edited 02-09-2024 02:49 AM
Hi Mark,
I assumed you were talking about a catalog item, but I realize you didn't state that.
If it's for a regular record, you can use this script:
answer = ifScript();
function ifScript() {
var fieldNames = ['field1', 'field2', 'field3', 'field4', 'field5', 'field6', 'field7', 'field8'];
var count = 0;
for (var i = 0; i < fieldNames.length; i++){
if (current[fieldNames[i]] == true){
count++;
}
}
return count > 1; //false if 1, true if more than 1
}
If it's indeed for a requested item with variables, you can use this script (I used true/false instead of yes/no before)
answer = ifScript();
function ifScript() {
var fieldNames = ['field1', 'field2', 'field3', 'field4', 'field5', 'field6', 'field7', 'field8'];
var count = 0;
for (var i = 0; i < fieldNames.length; i++){
if (current.variables[fieldNames[i]] == 'Yes'){
count++;
}
}
return count > 1; //false if 1, true if more than 1
}
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.