Glideajax script include

MohdF
Tera Contributor

Hi all,

When I am trying to auto populate caller's email, location and manager in the incident after changing the caller, it is auto populating the email and manager's field but not the location field, I am using client scripts and script include for this

This is my client script

 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
	var caller_details = g_form.getValue('caller_id');

	var ga = new GlideAjax('AutoPopulate_CallerInfo');
	ga.addParam('sysparm_name', 'getCallerInfo');
	ga.addParam('sysparm_value', caller_details);

	ga.getXML(callback);

	function callback(response){
		var answer = response.responseXML.documentElement.getAttribute("answer");
		var test = answer.split(',');

		g_form.setValue('u_email_id', test[0]);
		g_form.setValue('u_caller_s_location', test[1]);
		g_form.setValue('u_caller_s_manager', test[2]);
	}
	

}

 

 

 

and this is my script include

 

 

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

    getCallerInfo: function() {
        var sysIdofcaller = this.getParameter('sysparm_value');

        var x = new GlideRecord('sys_user');
        x.addQuery('sys_id', sysIdofcaller);
        x.query();
        if (x.next()) {
            return x.email+','+x.location+','+x.manager;

        }

        return '';


    },

    type: 'AutoPopulate_CallerInfo'
});

 

 

 Please help! anyone!

1 ACCEPTED SOLUTION

@MohdF ,

 

what type of field you have used for Callers location ? and are you referencing it to cmn_location table or not ?

please put an alert and check what you are getting ?

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

 

View solution in original post

12 REPLIES 12

Pratima Kalamka
Kilo Sage

swathisarang98
Giga Sage
Giga Sage

Hi @MohdF ,

 

I tried your code in my PDI all three field are getting populated, could you please try with a user record where  all three values are filled like EMAIL,manager and location,

 

swathisarang98_0-1717413819675.png

 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

MohdF
Tera Contributor

I don't why its not working I am using the users who have all the details email, location and mail

Please refer to the image attached.

Thank you!user_snow.jpgincident_snow.jpg

Hi @MohdF,

 

Please type cache.do in navigator. Also please try this below code:

var x = new GlideRecord('sys_user');
x.addQuery('sys_id', '62826bf03710200044e0bfc8bcbe5df1');
x.query();
if (x.next()) {
    gs.info(x.getValue('email') + ',' + x.getValue('location') + ',' + x.getValue('manager'));

}

 

Please user x.getValue instead of .email hope this will work out.

 

Please accept my solution if it works for you and thumps up.

 

Thanks

Jitendra

Please accept my solution if it works for and thumps up.

@MohdF ,

 

what type of field you have used for Callers location ? and are you referencing it to cmn_location table or not ?

please put an alert and check what you are getting ?

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang