- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2020 05:59 AM
Hi ,
I need to separate each of these below arrays into 8 separate arrays so that I can pass these to a method. Now the length shows as the length of total string and not 8.
contentMap received :[
{"column":"u_kb_index","content":"SCOM_CUSTOM_Service-Health_BY0VBV","table":"u_kb_template_gems","number":"KB0022149"},
{"column":"u_kb_source","content":"SCOM","table":"u_kb_template_gems","number":"KB0022149"},
{"column":"u_kb_monitor_description","content":"<p>QA Airwatch API Service is Down<br /><br /> <span style=\"font-family: Calibri;\">Summary: </span><br /><span style=\"font-family: Calibri;\">The Airwatch Application Service or IIS or World Wide Web Publishing Service is not running</span></p>","table":"u_kb_template_gems","number":"KB0022149"}]
Please help.
Thanks in Advance,
Chinmayee Mishra
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2020 06:21 AM
So that seems to be alright now. You have 8 entries. So length is returning 8?
Then you can loop through that like:
for(var i=0;i<contentArr.length;i++){
gs.info(JSON.stringify(contentArr[i]));
//do something with the object
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2020 07:24 AM
Glad to know that you got the approach.
Did you mistakenly mark other answer as correct?
As I see same comments were provided before from my end above pretty well (first).
You can only mark 1 response as correct. I am not against marking other answer as correct.
Please mark appropriate response as correct.
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
10-25-2020 07:27 AM
Seems fine, I was first with the correct parsing and handling. So it was marked Correct accordingly. Does not seem like a mistake to me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2020 07:59 AM
Hi Ankur,
In my email I first got Willem's response and tried. It worked and hence I marked his response as correct. Please don't feel bad. It would be unfair to him if I remove "correct" marking from his response.
You are a genius and I have so many more questions to come. 😛
Thank you so much for helping us.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2020 08:13 AM
No worries.
Have a nice day
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
10-25-2020 06:09 AM
If it returns length of all characters, it might not be in the right format.
(assuming contentMap is the name of the variable that stores the array(like) value)
Can you log: typof contentMap
Try converting it by parsing it:
var arrayA = JSON.parse(contentMap);
And then getting the length:
arrayA.length
With that you can loop through it and use each individual result as you please.