I have created a map of type
Map<Id, Set<Id>> missingProduct= new Map<Id, Set<Id>>();
Set<Id> prd = new Set<Id>();
However on running the loop and storing the values duplicate map values are been stored without removing the value of the previous map.
for(Product_Objective__c prdObj :allObjectives ){
prdobject = new Product_Objective__c ();
prd.add(prdobject.Product__c);
missingProduct.put(prdobject.Account__c,prd);
system.debug('missingProduct'+missingProduct);
}
Map is having the values of the previous set also stored with all value. I am unable to make it null for new key.
Set<Id> prd = new Set<Id>();
Map.containsKey(key)
. – itzmukeshy7 Mar 28 '17 at 11:41