List Collector - Email Address

Mark94
Kilo Expert

Hi,

I have a catalog item with a list collector variable. It's listing all the users in the sys_user table. I want it to collect the email addresses of all the users selected.

I thought this could be done by adding something into the "reference qual" or "Variable Attributes" fields, but I have so far been unable to find a way.

Any ideas?

Many thanks,

Mark.

 

1 ACCEPTED SOLUTION

Manas Kandekar
Kilo Guru

Hi

Have you tried onChange client script and script include to achieve this?

find_real_file.png

 

find_real_file.png

 

If my answer helped you in any way, please then mark it correct and helpful.

Kind regards,
Manas

View solution in original post

6 REPLIES 6

Can you show screenshots?

And check if you are getting logs in 'system log' printed by gs.log(emails).

Hi Mark,

   We can also use geXMLAnswer() Instead of getXML()

  Try this one 

Onchange client script for change of List collector variable:

 

var gaPhone = new GlideAjax('GetEmails');
gaPhone.addParam('sysparm_name', 'populate_email');
gaPhone.addParam('sysparm_users', newValue);
gaPhone.getXMLAnswer(_handleResponse);
function _handleResponse(response) {
alert(response);
}
 
Script include:
var GetEmails= Class.create();
GetEmails.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    populate_email: function() {
var userArr = this.getParameter('sysparm_users').toString().split(',');
var emailArr = [];
for(var i = 0; i < userArr.length; i++) {
var grUser = new GlideRecord('sys_user');
 
if(grUser.get(userArr[i].toString())) {
emailArr.push(grUser.getValue('email'));
}
}
emailArr.join();
return emailArr.toString();
},
    type: 'GetEmails'
});