Split() method in workflow does not work

Nancy8
Giga Contributor

The requirement is to get a list of users from catalog item form and assigned them to groups.  I used the variable type:list collector for variable "Select User (g_1_user).  In my workflow, I used "Run Script" to run the following script:

find_real_file.png

In logs, I got a list of user returned: , but when I was trying to use "split(",")" method to split each user, I got "undefined" the error (size====undefined).  It seems "Split() " doesn't in workflow.  Any suggestion how to split a list of users in workflow?

find_real_file.png

 

1 ACCEPTED SOLUTION

Cool - please mark as answered if this answered your question. Thanks

View solution in original post

7 REPLIES 7

Jon Barnes
Kilo Sage

it may be that that variable is not in a string format when you split it. Just to be sure, can you do this:

 

var group1Users = workflow.variables.g_1_user.toString();

SanjivMeher
Kilo Patron
Kilo Patron

Also make sure to check, the user list is not empty

if (group1Users!='')

addGroupMembers(groupName1,group1Users);


Please mark this response as correct or helpful if it assisted you with your question.

erik_brostrom
Mega Guru

As Jon stated, in workflow to need to .toString() your list collector variable before splitting it.

i.e.

var lc = current.variables.list_collector.toString().split(',');

it works when use toString()