Having trouble populating a Repeat Box with objects from a JSON document. Despite my efforts, it keeps duplicating the first item instead of adding each one individually. Any ideas on what might be causing this issue?
Below is the code I am currently using to extract data from the 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");
}
Provided below 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"
},
...
]
}
Although the correct number of results are being fetched, the Repeat Box displays them all using the data from the initial entry only. Can you point out any errors within my for loop implementation?