Add multiple email addresses to List Collector on Service Portal/Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2020 10:20 AM
Hello.
Within a catalog item, we have two fields. One is for the user's name the other for their email address.
I've used the table 'sys_user' for both fields. When the user's name is populated, I have it automatically adding their email address to the specific email field, both with 'List Collector' as their variable type.
Issue I am having, is if multiple users are added to the User field, no email address (even previously displayed for the first user) will be displayed. How do I get each additional email address to be displayed in the List Collector / email field?
- Labels:
-
Incident Management
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2020 10:23 AM
Hi Mairvette,
Can you please share your script here.
Thanks,
Mohit Kaushik
Mohit Kaushik
ServiceNow MVP (2023-2025)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2020 10:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2020 11:13 AM
In your script you are getting a comma separated sys_ids and that's why you are not able to use getReference properly to get the email Id of unique record.
Instead you can change your script like this:
var ids = g_form.getValue('users_add').toString().split(','); // to get the comma separated ids.
var emailids='';
var user;
for(var i=0; i<ids.length;i++)
{
user = new GlideRecord('sys_user');
user.query('sys_id',ids[i]);
user.query(myCallbackFunction);
}
function myCallbackFunction(user){
if(user.next())
{
if(emailids ='')
{
emailids=user.email; // for first record
}
else{
emailds = emailids + ','+user.email; if multiple records
}
}
}
g_form.setValue('email_address_add',emailds);
This should solve the purpose. Please try and let me know!!
Mohit Kaushik
ServiceNow MVP (2023-2025)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2020 11:46 AM