I'm creating a map in javascript I have a key as String and Value as SObject here is the function for the map
var oMap = {};
function addValueToKey(key, value) {
oMap[key] = finAccountMap[key] || [];
oMap[key].push(value);
}
addValueToKey('Blue',accOne);
addValueToKey('Green',accTwo);
then I JSON.stringify the map then I pass the map to apex controller as String Json
@AuraEnabled public static List<FinAccount__c > actionUpdateFinAccount(String oMapJson) {
Map<String, Object> accMap = (Map<String, Object>)JSON.deserializeUntyped(oMapJson);
for (String key : accMap.keySet()){
System.debug('field name is ' + key);
Object accObj = accMap.get(key);
System.debug(accObj);
System.debug(accObj.Id);
}
}
the problem is that I will get error if I do accObj.Id which is
Variable does not exist: Id
after the deserialize my data will look like this
{Blue=({Account__c=0011D00000GabRNQAZ, Id=a061D000001BI7lQAG, Name=color}), Green=({Account__c=0011D00000GabRNQAZ, Id=a061D000001BI7HQAW, Name=color})}
also System.debug(accObj); will look like this
({Account__c=0011D00000GabRNQAZ, Id=a061D000001BI7HQAW, Name=color})