Comma separated values not returning from script include to client script

Chenab Khanna
Tera Expert

Hi

I have a string variable where users enter names by comma separating( field name - colleagues1) and i have another variable which will store the email address of those names by comma separated.

I wrote a catalog client script and script include for this. It worked fine when the variable (colleagues1) where users are selected is a list collector but if the variable is a string, it isnt going in the loop and always just returning email address of 1st user selected. 

Please find the script include - 

find_real_file.png

I checked, the values are coming correctly from client script and the for loop is also running fine.

Works first time, but subsequently, it isn't going to else condition

1 ACCEPTED SOLUTION

Hi,

might be some space in the name

please try this and trim the value

gr.addQuery('name', count[i].trim());

Also did you check those users are having the email with @ whatever your query is

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

16 REPLIES 16

Its still 0 @Ankur Bawiskar 

I tried below script include - 

find_real_file.png

TThis works fine for first name. I am able to get email id of first user name i have put but unable to get subesquent. I checked, loop is running fine. I am even getting count[i] separately but not why it get stuck inside while. I tried putting if instead of that while but still not working

Hi,

might be some space in the name

please try this and trim the value

gr.addQuery('name', count[i].trim());

Also did you check those users are having the email with @ whatever your query is

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

It works now. Thanks

@Chenab Khanna 

Nice to know.

Please mark my response as correct and helpful to close the thread so that others can be benefited by this.

Happy learning.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Jaspal Singh
Mega Patron
Mega Patron

Hi Chenab,

 

Can you replace

if(i==0)

{

gp=gr.email;}

else

{

gp=gp+','+gr.email;}

with

gp=gr.email+','+gp;

 

Also, var gp=''; instead of var gp=' ';