GlideAjax
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2024 04:41 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2024 06:08 AM
Do you have any other client scripts or UI policies affecting this field/variable?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2024 06:18 AM - edited ‎09-26-2024 06:20 AM
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)