GlideAjax

desaiakash0
Tera Contributor

I've created a GlideAjax script to automatically populate the location field whenever a caller is selected. However, the location is displayed correctly initially but then disappears automatically. Additionally, attempts to display the location through an alert message result in 'null' being shown.I have attached the screenshots of Script inlcude code, client scirpt code and output window.

I'm seeking assistance to resolve this issue.



2 REPLIES 2

Brad Bowman
Kilo Patron
Kilo Patron

Do you have any other client scripts or UI policies affecting this field/variable?

Zach Koch
Giga Sage
Giga Sage

In your Script Include, it needs to look like this as you have to use this.getParameter('<your_parameter>') to get your param

 

 

getCallerLocation: function() {
    var userID = this.getParameter('sysparm_caller_id');
    var userRecord = new GlideRecord('sys_user');
    userRecord.addQuery('caller_id', userID) //or whatever field you are using this data to search on if it's not caller_id
    userRecord.query()
    if (userRecord.next()) {
        return userRecord.location.name;
    } else {
        return 'Record not found';
    }
}

 

Here is a great link that breaks it down

GlideAjax Example Cheat Sheet (UPDATED) 

If this information helped resolve your issue, please remember to mark response correct and thumbs up to help future community members on this information, thanks!