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

shloke04
Kilo Patron

Hi @MohdF ,

 

Use the solution listed in below thread:

https://www.servicenow.com/community/guided-learning-itsm/i-want-to-auto-populate-the-user-details-b... 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Community Alums
Not applicable

Hi @MohdF ,

I tried your problem in my PDI it seems there is no issue in your code. May be there is no manager assigned to that user. Please check that.

 

SarthakKashyap_0-1717345424571.png

 

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards 

Sarthak

Hi @Community Alums 

 

I think you misunderstood my problem, my problem is that the location field isn't auto populating but the manager and email field is populating.

Please respond if you get my problem.

Community Alums
Not applicable

Hi @MohdF ,

Did you check in user table that Location value is present over there or not ? If not please give some location there.

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards 

Sarthak