
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2021 10:15 AM
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:
catalog client script :
script include:
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2021 04:22 PM
solution.
calling isPublic() solved the issue.
Reference:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2021 12:08 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2021 12:19 PM
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).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2021 12:56 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2021 01:46 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2021 01:53 PM
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