
- 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 02:49 AM
Hi,
are those values the name field of sys_user then the script shared by me should work fine
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 02:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2020 03:51 AM
Hi,
are you using the script I shared or the one which you posted in the question
if you are using script I shared please share complete client script and script include function
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 03:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2020 04:09 AM
Hi,
since you informed the row count is 0 so it means the query is not happening
the variable colleagues1 is string type and holds the name so you should query with the name field
Did you check exact name is present in the sys_user table
getEmailSharePoint: function(){
var userName = this.getParameter('sysparm_s');
var arr = userName.toString().split(',');
var arr1 = [];
var userRec = new GlideRecord('sys_user');
userRec.addActiveQuery();
userRec.addQuery('name', 'IN', arr); // see change here
userRec.query();
gs.info('Row Count is' + userRec.getRowCount());
while(userRec.next()){
arr1.push(userRec.email.toString());
}
gs.info('Array of email is' + arr1.toString());
return arr1.toString();
},
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader