Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Glide Ajax and Script Include to fetch email ID of loggedin user selected

jyothesna
Tera Contributor

 

I have wrote a Script Include & Glide Ajax to fetch email ID of User. Following are the script include and client script which I have written. I am getting a Null value in answer.

 

Script include:

 

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

getEmail: function() {


var uid = this.getParameter('sysparm_usrid');
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',uid);
gr.query();
if(gr.next()) {
return gr.email;
}
},
type: 'JyoEmailPopulateSI'
});

 

 

ClientScript:

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}

//Type appropriate comment here, and begin script below
var ga = new GlideAjax('JyoEmailPopulateSI');
ga.addParam('sysparm_user', 'getEmail');
var getValue = g_form.getValue('username');
ga.addParam('sysparm_usrid',getValue);

ga.getXML(populateEmailid);

function populateEmailid(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert("Value in answer " + answer);
g_form.setValue('emaild',answer);
}

}

1 ACCEPTED SOLUTION

Kamil Smusz
Kilo Sage

Hi @jyothesna ,

 

You have issue in GlideAjax. You need to add sysparm_name to select function inside Script Include so in your case ga.addParam('sysparm_name', 'getEmail');

View solution in original post

1 REPLY 1

Kamil Smusz
Kilo Sage

Hi @jyothesna ,

 

You have issue in GlideAjax. You need to add sysparm_name to select function inside Script Include so in your case ga.addParam('sysparm_name', 'getEmail');