I am trying to get a Repeat Box to fill up with objects from a JSON document. However, it wont add each item but rather multiple copies of the first item in the JSON document. Any clues as to why?
I am using the following code to pull objects from my JSON document.
function Project_WebClient1_OnSyndicationSuccess(e){
var FactsArray = [];
var parsedResponse = JSON.parse(this.responseText);
var numOfFacts = parsedResponse.results.length;
for (var i = 0; i < numOfFacts; i++) {
var FactsObject = {};
FactsObject.heading = parsedResponse.results[i].heading;
FactsObject.ReleaseDate = parsedResponse.results[i].ReleaseDate;
FactsObject.url = parsedResponse.results[i].url;
FactsArray.push(FactsObject);
log(FactsObject.heading);
}
Pages.pgFundInfo.RepeatBox1.dataSource = FactsArray;
Pages.pgFundInfo.RepeatBox1.refresh();
Data.notify("Data.FactSheets_OutDSetFactSheets.FactSheetsId");
}
Here is the JSON Document:
{
"results": [
{
"FactFile": {
"__type": "File",
"name": "Sept2015.pdf",
"url": "http://files.sample.com/Sept2015.pdf"
},
"Heading": "Medium Growth September",
"ReleaseDate": {
"__type": "Date",
"iso": "2015-09-30T06:29:00.000Z"
},
"createdAt": "2015-10-31T06:28:03.189Z",
"objectId": "XUS4guS8Hu",
"updatedAt": "2015-11-04T10:00:37.092Z"
},
{
"FactFile": {
"__type": "File",
"name": "MedConsGrowthSept2015.pdf",
"url": "http://files.sample.com/MedConsGrowthSept2015.pdf"
},
"Heading": "Medium-Conservative Growth September",
"ReleaseDate": {
"__type": "Date",
"iso": "2015-09-30T06:30:00.000Z"
},
"createdAt": "2015-10-31T06:31:18.502Z",
"objectId": "LOLyM2KX5g",
"updatedAt": "2015-11-04T10:00:40.561Z"
},
{
"FactFile": {
"__type": "File",
"name": "HiMedGrowthSept2015.pdf",
"url": "http://files.sample.com/HiMedGrowthSept2015.pdf"
},
"Heading": "High-Medium Growth September",
"ReleaseDate": {
"__type": "Date",
"iso": "2015-09-30T06:50:00.000Z"
},
"createdAt": "2015-10-31T06:50:54.367Z",
"objectId": "I59ZKa5Onq",
"updatedAt": "2015-11-04T10:00:47.268Z"
},
{
"FactFile": {
"__type": "File",
"name": "HiGrowthSept2015.pdf",
"url": "http://files.sample.com/HiGrowthSept2015.pdf"
},
"Heading": "High Growth September",
"ReleaseDate": {
"__type": "Date",
"iso": "2015-09-30T06:52:00.000Z"
},
"createdAt": "2015-10-31T06:52:05.618Z",
"objectId": "m4vkEDBgRr",
"updatedAt": "2015-11-04T10:00:52.294Z"
},
{
"FactFile": {
"__type": "File",
"name": "ConsGrowthSept2015.pdf",
"url": "http://files.sample.com/ConsGrowthSept2015.pdf"
},
"Heading": "Conservative Growth September",
"ReleaseDate": {
"__type": "Date",
"iso": "2015-09-30T06:53:00.000Z"
},
"createdAt": "2015-10-31T06:53:27.399Z",
"objectId": "bthR88Ck8y",
"updatedAt": "2015-11-04T10:00:55.160Z"
},
{
"FactFile": {
"__type": "File",
"name": "PerformerSept2015.pdf",
"url": "http://files.sample.com/PerformerSept2015.pdf"
},
"Heading": "Multi-Asset Class Portfolio Range September",
"ReleaseDate": {
"__type": "Date",
"iso": "2015-09-30T06:55:00.000Z"
},
"createdAt": "2015-10-31T06:55:32.021Z",
"objectId": "JluOn1O0IO",
"updatedAt": "2015-11-04T10:00:58.839Z"
}
]
}
I am getting the correct number of results coming through, however, inside my repeatbox, it lists them but all using the data from the first entry and not the rest.
What am I doing wrong in my for loop for this?