- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2020 02:38 PM
I'm trying to create a global variable in a Catalog Client Script, available for all other client scripts to access:
var globalVar = '';
function onLoad() {
var ajax = new GlideAjax('TestScriptInclude');
ajax.addParam('sysparm_name', 'returnProperty');
ajax.getXMLAnswer(function(answer) {
globalVar = answer;
});
}
This onLoad client script calls to the server and gets an array of values that I need for other client scripts to use with onChange and onSubmit.
How do I set this up correctly and access it in my other catalog client scripts?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2020 03:45 PM
Be sure to uncheck "Isolate script" on all scripts using global variable.
- Declare global variable in onLoad.
- Set value onChange script.
- Can use it on other onChange script
Execution output:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2022 10:11 AM
Hi, I have tried as described above but in the onChange function the global variable is not defined. I have follwoing error message:
ReferenceError: globalVarTest is not defined
Isolate script on all script is unchecked