GlideAjax in UI Policy Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2023 01:23 AM
Hi All,
I'm trying to use GlideAjax in a UI Policy script but get an error : 'TypeError - Cannot read property 'execute' of undefined.
The script:
function onCondition(){
var APPROVED_VALUE = '1';
var NUMBER = 1;
var condition = g_form.getValue('state') == APPROVED_VALUE;
var queryFields = new GlideAjax('name');
queryFields.addParam('sysparm_name', 'function_name');
queryFields.addParam('number', number);
queryFields.getXMLAnswer(function(response){ functionName(response, condition)});
}
functoin(response, condition){
response = JSON.parse(response);
for(var i = 0; i < response.length; i++){
g_form.setDisplay(response[i], condition);
}
}
Does anyone know how to fix this?
Thanks:)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2023 05:32 AM
@Snow Tomcal There is a typo in your function handing response functoin(response, condition){
Please fix the typo and check if the code works for you.
function(response, condition){
response = JSON.parse(response);
for(var i = 0; i < response.length; i++){
g_form.setDisplay(response[i], condition);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2025 07:50 AM
Moving the response function inside the onCondition() fixed it for me.