Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

have an error in virtual Agent script "org.mozilla.javascript.NativeJavaObject@cd9054a4"

Ashwini Jadhao
Giga Guru

Hi,

I am trying to add choice list of impact in the chatbot of virtual agent but shows an error as "org.mozilla.javascript.NativeJavaObject@cd9054a4"

And here is my code

(function execute() {
var options = [];

var choices = newGlideChoiceList();
// Getting all the choices for impact.
var choiceList = choices.getChoiceList('incident', 'impact');
for (var i=0; i < choiceList.getSize(); i++) {
options.push({'value': choiceList.getChoice(i).getValue(), 'label': choiceList.getChoice(i).getLabel()});
}
 
return options;
})();
1 ACCEPTED SOLUTION

Mark Roethof
Tera Patron
Tera Patron

Hi there,

A month or 2 ago, I helped a fellow community member who had similar error messages. Somehow, adding in your options.push, after the getLabel() + "" fixed it. Maybe that works for you also?

https://community.servicenow.com/community?id=community_question&sys_id=1b6cf6b0db71bb04feb1a851ca96...

Give it a try.

options.push({'value': choiceList.getChoice(i).getValue(), 'label': choiceList.getChoice(i).getLabel() + ''});

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

2 REPLIES 2

Mark Roethof
Tera Patron
Tera Patron

Hi there,

A month or 2 ago, I helped a fellow community member who had similar error messages. Somehow, adding in your options.push, after the getLabel() + "" fixed it. Maybe that works for you also?

https://community.servicenow.com/community?id=community_question&sys_id=1b6cf6b0db71bb04feb1a851ca96...

Give it a try.

options.push({'value': choiceList.getChoice(i).getValue(), 'label': choiceList.getChoice(i).getLabel() + ''});

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

vkachineni
Kilo Sage

return JSON.stringify(options);

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022