Getting error org.mozilla.javascript.NativeArray
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â09-21-2022 07:09 AM
I have a requirement where I want to fetch all the computer names from cmdb_ci_computer table that are assigned to requester and also want to set the field with newly assigned computer.
there is existing script include as well as catalog client script but when I used array it throws the error org.mozilla.javascript.NativeArray
Please suggest ,what is going wrong here
Catalog client script:-
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('PL4UserServiceAjax');
ga.addParam('sysparm_name', 'getUserComputer');
ga.addParam('sysparm_user', newValue);
ga.getXMLAnswer(setComputer);
}
function setComputer(response){
g_form.setValue('Computername', response);
}
Script include :-
getUserComputer: function(userId) {
var host =[];
var comp = new GlideRecord("cmdb_ci_computer");
comp.addQuery("assigned_to", userId);
// comp.orderByDesc("sys_created_on");
comp.query();
while (comp.next()) {
var str = (comp.getValue("name"));
host.push(str);
}
return host;
},
Reference Qualifier:-assigned_to=gs.getUserID()^install_status!=7^sys_class_name=cmdb_ci_computer^EQ
Default Value:- javascript: new PL4UserService().getUserComputer(gs.getUserID())
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â09-23-2022 12:47 AM
Hi,
then you need to debug the other script include which is getting called from the main script include
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â09-23-2022 12:51 AM
Hi Ankur,
In that script only these three lines are there
getUserComputer: function(){
var computerID;
var userId = this.getParameter("sysparm_user");
var computer = new PL4UserService().getUserComputer(userId);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â09-23-2022 12:56 AM
Hi,
then you need to debug this script include and function
var computer = new PL4UserService().getUserComputer(userId);
regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â09-23-2022 01:08 AM
Hi
PL4UserService() is script include with the below code
getUserComputer: function() {
var host = [];
var userId = this.getParameter('sysparm_user');
var comp = new GlideRecord("cmdb_ci_computer");
comp.addQuery("assigned_to", userId);
comp.orderByDesc("sys_created_on");
comp.query();
while (comp.next()) {
var str = comp.getValue("name");
host.push(str);
}
var arrayUtil = new global.ArrayUtil();
host = arrayUtil.unique(host);
return host.toString();
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â03-28-2024 03:52 AM
Hi Ankur,
Hope you can help. Trying to apply your code above (not as a function) in a dynamic content block. I want the service offering names pushed to an array and then display the array items as a string and display. Below is my code so far.