I have an attribute of type CustomSetting__c(which is a list type of CUSTOM SETTING) and I want to iterate over it to fetch its each record, and print that record's certain fields. I am unable to iterate over it and '.length' property is givng me error as:
[Cannot read property 'length' of undefined]
Please find related code:
Lightning component attribute:
<aura:attribute name="customSettingList" type="CustomSetting__c[]" />
On click of certain button, I want to go to helper of this component and execute this code:
Helper.js:
//some code before this
component.set("v.customSettingList", response.getReturnValue());
//some code after this statement
var customSettingList=[];
customSettingList=component.get("v.customSettingList");
for(var i=0;i<customSettingList.length;i++){
console.log('customSettingList type: '+ customSettingList[i].Type__c);
}
where Type__c is a custom field of this custom setting.
What is the reason for this? How can I access the field values of individual records from list?
Note: This is a list type of custom setting if that has to do anything with this.(Can we not access list custom setting in JS?)