GlideAjax in UI Policy Script

Snow Tomcal
Tera Expert

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:)

2 REPLIES 2

Sandeep Rajput
Tera Patron
Tera Patron

@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);

}

}

 

Oleksandra Guzo
Tera Contributor

Moving the response function inside the onCondition() fixed it for me.