
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2020 08:49 AM
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 -
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2020 04:47 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2020 04:29 AM
Its still 0
I tried below script include -
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2020 04:47 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2020 05:00 AM
It works now. Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2020 05:05 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2020 01:22 AM
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=' ';