Add multiple email addresses to List Collector on Service Portal/Catalog

Mairvette Tuck1
Mega Contributor

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?

find_real_file.pngfind_real_file.png

30 REPLIES 30

Mohit Kaushik
Mega Sage
Mega Sage

Hi Mairvette,

Can you please share your script here.

 

Thanks,

Mohit Kaushik

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)

the only script is the catalog client script, to autopopulate the email field once the user is added to the user field:
find_real_file.png

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!!

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)

Hi @Mohit Kaushik  - getting this error:

find_real_file.png