The CreatorCon Call for Content is officially open! Get started here.

Glide AJAX is not working ( from a catalog client script)

Gal1
Kilo Guru

Hi Experts,

My goal is to be able to call a server script with glideAjax from a catalog client script, which related to a record producer. right now I'm getting null as an answer (from the glideAjax) and also my logs on the script include are not executed. 

Please help, what am I missing?

 

 

record producer:

 

find_real_file.png

find_real_file.png

find_real_file.png

catalog client script : 

find_real_file.png

 

script include:

 

find_real_file.png

1 ACCEPTED SOLUTION
26 REPLIES 26

ccajohnson
Kilo Sage

Perhaps if we knew what the goal is with the Script include it may help us understand what is missing.

Are you trying to fill in a field based upon a selection, or something else?

Is the script include in the Global Scope, or a different application scope? If it is different, you would need to indicate that within the Catalog Client Script, for example:

    var gaSymptomCode = new GlideAjax('global.IND_Symptoms');

is different than:

    var gaSymptomCode = new GlideAjax('IND_symptoms');

Look at the API Name field on the Script include record, and use that in your script include call.

both the script include and client script are in the same scoped application - customer service.

I tried also to add the global prefix and it didn't help.

The goal is to populate another field based on the value of the subcategory variable(the one that has on change catalog client script). as you see I don't have the code for it right now - that's why I didn't mention it. 

right now I'm stuck in this phase where I don't get the answer from the script include (or/And the script include is not called).

 

You need to look at the API Name field on the Script Include Record and use that when calling the script include from your client script. My guess is that it is something like: sn_customer_service.IND_Symptoms. Just to be sure, you also want to change the Accessible from field on the script include record to be: All application scopes.

If you can access your record producer from the classic view, you should be able to call the portion of the Catalog Client Script using the JavaScript Executor command by pressing the following keys: <Control><Shift><alt><J>
Then you can copy the portion of the script you want to test and paste in the window.

    var symptom_category = g_form.getValue('subcategory');
    var gaSymptomCode = new GlideAjax('sn_cust_service.IND_Symptoms');
    gaSymptomCode.addParam('sysparm_name', 'IND_Symptom_code_RP_function');
    gaSymptomCode.addParam('sysparm_symptom_category', symptom_category);

    gaSymptomCode.getXMLAnswer(getAnswer);
        function getAnswer(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
        alert(answer);
    }

This should help you build while you test. Once all works as expected, then you can edit your Catalog Client Script accordingly

 

it is not possible to change the 'Accessible from' field but I did try to open a new script include and to use it instead. and this time I calling the script include with the right prefix, and still no logs and answer is null.

 

find_real_file.png

find_real_file.png

I tried the part of the Java script executor and ran this:

 

var symptom_category = g_form.getValue('subcategory');
var gaSymptomCode = new GlideAjax('sn_customerservice.IND_Symptoms_tst');
gaSymptomCode.addParam('sysparm_name', 'IND_Symptom_code_RP_function');
gaSymptomCode.addParam('sysparm_symptom_category', symptom_category);

gaSymptomCode.getXMLAnswer(getAnswer);
function getAnswer(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
}

 

and I have the logs now (from the script include).. but when I'm testing it from the record producer page(from the portal - see screenshot) its not working and there are no logs

find_real_file.png