You need to sign in to do that
Don't have an account?

How to update sObject inside Map
Is there a way we can update List or sObject inside Map?
Map<id,Opportunity> oppMap = new Map<id,Opportunity>([select id, Name from opportunity]);
oppMap.put(OPPORTUNITY_ID, Opportunity.set(1,'oppName')); //This is currently not available I am just showing you an example.
update Map.values();
I found Something intersting.
Map<id,Opportunity> oppMap = new Map<id,Opportunity>();
oppMap.put('006d000000Cu0fj', new Opportunity(id = '006d000000Cu0fj', name= 'updated Opp'));
update oppMap.values();
oppMap.get(OPPORTUNITY_ID).Name='OppName';
You can also iterate through the records, like this:
for(opportunity record:oppmap.values()) {
// update record field values
}
Thanks for your update but I am specifically looking to update sobject within Map it self. I am getting System.LimitException: Too many code statements: 200001 Error. So I if I do for loop its giving me this error.