Variable attribute to show email id from username in list collector

Bhuvanesh Babu
Giga Expert

Hi Team, 

I need display auto populate email ids in the List Collector of a the users selected in another List collector in Portal.

I achieved this using Script include and Client script.

but can someone help me to show the email id instead of name in Signer email if Field using variable attributes in the variable

find_real_file.png

find_real_file.png

Script Include

var getSigneremailid = Class.create();
getSigneremailid.prototype = Object.extendsObject(AbstractAjaxProcessor, {

getEmailid: function() {
var signeremail = this.getParameter('sysparm_signeremail');
var users = signeremail.split(','); // splits the answer by the de-limiter ","
var str = '';

for (var i = 0; i < users.length; i++) {

var gr = new GlideRecord("sys_user");
gr.addQuery("sys_id", users[i]);
gr.query();
if (gr.next()) {
// str = str + gr.email + ',';
str = gr.sys_id;

}
}
return str;
},

type: 'getSigneremailid'
});

 

Catalog Client Script

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('getSigneremailid'); //call script Include
ga.addParam('sysparm_name', 'getEmailid'); //call Required function within Script Include
ga.addParam('sysparm_signeremail', newValue);
ga.getXML(callback);

function callback(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer != null) {
g_form.setValue("signer_email", answer); // sets value to the field in the portal
} else if (answer == null) {
g_form.setValue("signer_email", '');
}
}
}

 

Regards,

babu