- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2018 12:18 PM
I couldn't figure out why I am getting list of [object Object] instead of incident numbers in client side. Here is screenshot example,
According to gs.log from ajax script, it able to display 16 correct incident number,
I am pretty sure I am not using a right returnJSON function. Do I need to decode or something?
Here a sample of my script,
var groupId = 'ad057f9d4f374200c93959dd0210c704';
alert("Group name is " + groupId);
var ga = new GlideAjax('OpenIncidents');
ga.addParam('sysparm_name', 'getincidents');
ga.addParam('sysparm_item', groupId);
ga.getXML(IncidentsParse);
function IncidentsParse(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
answer = answer.evalJSON();
//alert(answer.length);
var count = 1;
for(var i = 0; i < answer.length; i++)
{
var myTr = "myTr" + count;
var ticketTd = "ticketTd" + count;
alert("ticket is "+ answer[i]);
var row = document.createElement("tr");
row.setAttribute("id", myTr);
document.getElementById("myBody").appendChild(row);
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2018 01:14 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2018 12:41 PM
Can you replace this line
answer = answer.evalJSON();
with
answer = JSON.parse(answer);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2018 12:53 PM
I still get same results of [object Object] with answer = JSON.parse(answer);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2018 12:55 PM
Looks like little modification required in for loop as well.
Please change this
for(var i = 0; i < answer.length; i++)
to
for(var i = 0; i < answer.length; i++)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2018 01:01 PM
< has nothing to do with error and plus that script is in Jelly which use html tag. Using "<" will cause unrecognizable script error so < will need to use for "<" in Jelly.