Script include returning "org.mozilla.javascript.NativeArray"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2020 12:43 AM
Hi Techies,
My requirement is to populate "database" variable , the values of this "database" variable are populate based on another variable "Landscape". So I wrote below onChange catalog client script and script include.
Script include returning something like "org.mozilla.javascript.NativeArray" . Please find below scripts and let me know what causing this issue.
Catalog Client Script:
function onChange(control, oldValue, newValue, isLoading) { var ga = new GlideAjax('ITSM_Database_oracle_choices'); function UpdateChoiceValues(response) { |
Script Include:
var ITSM_Database_oracle_choices = Class.create(); var land = this.getParameter('sysparm_land_name'); } type: 'ITSM_Database_oracle_choices' |
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2020 07:05 AM
Thats because when you send date from server to client (or vice-versa) it considers the returned object as String. Objects cannnot be transmitted over internet (http).
So you need to send it as any form of string (including JSON string) and then parse (or split) it on other end.
I see you are doing split on the client side so that good.
Only change you need is to replace last line in your script include function i.e.
return answer;
to
return answer.toString();
Hope this will solve your issue!
-Tanaji
Please mark response correct/helpful if applicable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2023 11:37 AM
hello Sir This is very helpful to me. Could you please explain what needs to be done in client script side?
Actually from my script include I am returning an array say arr1=["30","260"]. Now when I get the result in my console.log I see 30,260 but I don't know how to separate them.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2020 10:45 PM
Server Side Change:
var answer = ar;
return answer;
to
var answer = JSON.stringify(ar);
return answer;
Client Side Change:
strOption = answer.split(',');
to
strOption = JSON.parse(answer);
Explanation:
Everything is an object in JS, even Arrays.
var a = [1,2,3];
typeof (a) // returns "object"
JSON stringify is an easy way to pass it through as a string and convert it back to an array afterwords. The GlideAjax calls do not like passing non strings through as the response answer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2020 12:06 PM
Hey Mike,
The changes you suggested works fine for me, thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2020 04:52 AM
Mike..
Works Perfect...