You need to sign in to do that
Don't have an account?
Looping through a Map
Hello Everyone,
I am new to salesforce and apex and still trying to learn the trade. I was wondering if someone could have a look and point me towards the right direction on the error I am getting:
I am capturing the Id and fields in a Map from an external webservice in the following format:
list<String> resultlist = new list<string>(); Map<String, list<string>> resultMap = new Map<String, list<String>>{}; resultMap.put(MSId,resultlist);// MSId is the id(key) and mslist are string values
Now I have to compare the Id with salesforce record Id and insert the fields into the record. I have taken following approach which is resulting in an error :
List<Me__c> Ms = [select id, name, quantity__c, amount__c, target__c where name in:resultMap.keyset()];//name is the id in this case system.debug(Ms); for(Me__c m: Ms){ //for(List<String> mapvalues:msmap.values()){ did not work?? for(String mapvalues:resultMap.keyset()){ //System.debug(mapvalues.costscore); m.amount__c = Double.valueof(resultMap.get(m.name).amount);//error....Initial term of field expression must be a concrete sobject } }
Now What am I not doing right here?? Or how can I achieve my goal?
I know there are a lot of Pros here. It's very clear to them...
Thanks everyone.