- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 05:54 PM
Hello,
I have been trying to configure a workflow to auto generate tasks based on list collector value selected. It is creating the task based on the 1st value selected, the other tasks will not generate.
I created an If Activity script in the workflow, but still only 1 task. Please provide me some guidance... Thank you
An if Activity Script is created for each variable value:
below is a script for one of the values:
answer = ifScript();
function ifScript() {
var arrayUtil = new ArrayUtil();
var list = current.variables.vm_select_a_service.getDisplayValue();
var arrayList = list.split(",");
if (arrayUtil.contains(arrayList, "Assign Voicemail")) {
return 'yes';
}
return 'no';
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 08:53 PM
Hi @Rhonda9
It's because when you obtain the display value at the line below, it produces a string separated by commas with spaces at the beginning of each element.
var list = current.variables.vm_select_a_service.getDisplayValue();
Example:
element0, Assign Voicemail, element2, etc
Consequently, the arrayUtil.contains in your if condition returns false as the text "Assign Voicemail" lacks the initial space.
For resolution, you can leverage indexOf for your if condition. like below
answer = ifScript();
function ifScript() {
var list = current.variables.vm_select_a_service.getDisplayValue();
if (list.indexOf("Assign Voicemail") >= 0) {
return 'yes';
}
return 'no';
}
Cheers,
Tai Vu

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 08:08 PM
Hi @Rhonda9
Can you please provide how your workflow is configured? what all activities used to create tasks (how many if activities?)
Which script is not working?
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 08:09 PM
You can try below:
answer = ifScript();
function ifScript() {
var arrayUtil = new ArrayUtil();
var list = current.variables.vm_select_a_service.getDisplayValue();
var arrayList = list.split(",");
if (arrayList.indexOf("Assign Voicemail")>-1) {
return 'yes';
}
return 'no';
}
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 08:53 PM
Hi @Rhonda9
It's because when you obtain the display value at the line below, it produces a string separated by commas with spaces at the beginning of each element.
var list = current.variables.vm_select_a_service.getDisplayValue();
Example:
element0, Assign Voicemail, element2, etc
Consequently, the arrayUtil.contains in your if condition returns false as the text "Assign Voicemail" lacks the initial space.
For resolution, you can leverage indexOf for your if condition. like below
answer = ifScript();
function ifScript() {
var list = current.variables.vm_select_a_service.getDisplayValue();
if (list.indexOf("Assign Voicemail") >= 0) {
return 'yes';
}
return 'no';
}
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2024 07:28 AM
@Tai Vu Thank you so much, it works!