I have a JSON response I receive from an endpoint, it is then deserialized, and all of the objects are stored in a custom object list (stored in the list variable "scope").
I am trying to place this list of custom objects into a map, however the objects have not been inserted it, and may not be inserted, how do I accomplish this since they do not have IDs? I am thinking I could iterate through the scope objects and assign incremental values?
The error I receive (which to my understanding is because the objects haven't been inserted and they do not have IDs):
Row with null Id at index: 0
Map<ID, Custom_Object__c> scopeAccountMap = new Map<ID, Custom_Object__c>(scope);
system.debug(scopeAccountMap.keyset());
for (ID idKey : scopeAccountMap.keyset()) {
Customer_Account__c a = scopeAccountMap.get(idKey);
Map<String, Object> fieldsToValue = a.getPopulatedFieldsAsMap();
}
Map
at all? The code you include here could just as well iterate over aList
, and the fact that your data seems to lack a unique identifier militates against using aMap
.