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

map and containskey
if(!TypeAmountMap.containsKey(Shot.type__c)){
TypeAmountMap.put(Shot.type__c,Shot.Amount__c);
system.debug('TypeAmountMap1'+TypeAmountMap); // every time I am getting records here
}else{
TypeAmountMap.put(Shot.type__c, TypeAmountMap.get(Shot.type__c)+Shot.Amount__c);
system.debug('TypeAmountMap2'+TypeAmountMap); // records are not getting created any time ....if i am inserting multiple records also. what can be the reason ? why not coming here
note: type__c : formula fiel
TypeAmountMap this map is having value type__c and amount__c which every time getting populated.
TypeAmountMap.put(Shot.type__c,Shot.Amount__c);
system.debug('TypeAmountMap1'+TypeAmountMap); // every time I am getting records here
}else{
TypeAmountMap.put(Shot.type__c, TypeAmountMap.get(Shot.type__c)+Shot.Amount__c);
system.debug('TypeAmountMap2'+TypeAmountMap); // records are not getting created any time ....if i am inserting multiple records also. what can be the reason ? why not coming here
note: type__c : formula fiel
TypeAmountMap this map is having value type__c and amount__c which every time getting populated.
Set<Id> setOfId = new Set<Id>();
for(Account acct :[SELECT Id,Name FROM Account]){
setOfId.add(acct.Id);
}
for(Contact con:[SELECT Id,LastName FROM Contact where AccountId IN:setOfId]){
if(!mapIdVsConatcts.containsKey(con.Id)){
mapIdVsConatcts.put(con.Id, new List<Contact>());
}
mapIdVsConatcts.get(con.Id).add(con);
}
System.debug('mapIdVsConatcts'+mapIdVsConatcts);
Map<id,Account> mapIdVsAccount = new Map<Id,Account>();
Set<Id> setOfId = new Set<Id>();
for(Account acct :[SELECT Id,Name FROM Account]){
mapIdVsConatcts.put(acct.Id, acct);
}