I am having problem to render below array with objects.
var newList = '{appointmentList}';
var apptList = JSON.parse(newList);
alert(newList);
alert result:
[{
"userId":"0051a000002BHA7AAO",
"subject":"Appcal blk",
"startDateTime":"2017-07-03T18:00:00.000Z",
"profileId":"a1C1a000000zkWXEAY",
"location":"Rm # 23-C48 in 177 Huntington Ave",
"id":"a160j000000BOgDAAW",
"endDateTime":"2017-07-03T19:00:00.000Z",
"duration":30,
"categoryType":"30-min Appts (shown on Public Calendar)",
"bookedSlotList":[],
"availableSlotList":
[{
"startDateTime":"2017-07-03T18:00:00.000Z",
"endDateTime":"2017-07-03T18:30:00.000Z"
},
{
"startDateTime":"2017-07-03T18:30:00.000Z",
"endDateTime":"2017-07-03T19:00:00.000Z"
}],
"availableBlockList":
[{
"startDateTime":"2017-07-03T18:00:00.000Z",
"endDateTime":"2017-07-03T19:00:00.000Z"
}],
"availability":"Any",
"appointmentTypeList":
[
"Phone"
]
}];
I am using for loop, but having problem with availableSlotList array.
if(apptList.length > 0) {
for(var i=0;i<apptList.length;i++) {
var catg = (catMap[apptList[i].categoryType] == 'Individual') ? '' : 'none';
var apptSize = JSON.stringify(apptList[i].availableBlockList);
//alert(apptSize+'---'+i);
var showAppt = (apptList[i].availableBlockList.length == 0) ? 'none' : '';
var noAppt = (apptList[i].availableBlockList.length == 0) ? '' : 'none';
html += '<table width="100%" style="font-size:13px;"><tr><td>'
html += '<apex:outputText value="' + apptList[i].startDateTime +' - '+ apptList[i].startDateTimee + '" style="font-weight:bold;margin-bottom:2px;" /> ';
html += '<apex:outputText value="(' + tzName + ')" style="font-weight: bold;" /></td></tr>';
html += '<tr style="display:' + catg + '">';
html += '<td class="tabLine" style="display:' + showAppt + '"><apex:outputText value="Appointments available during: " />';
html += '</td></tr></table>';
for(var j;j<apptList[i].availableSlotList) {
alert(apptList[i].availableSlotList.startDateTime);
}
}
}