I am having one req.
I am having 1 opportunityLineItem standard objects. It has 3 fields-Product_c, MType_c(Picklist) and MFactor__c(Percent).
I am having another object Config object. It has also same 3 fields similar to opportunityLineItem object.
So when user comes to OppLineitem and insert/update any line item by changing the its media type value, it will check following thing
If (chosen media type from line and media type from config obj matches) and (product from opplineitem and product from config obj matches) then assign config_c.MFactor_c to Opportunitylineitem.MFactor__c
This what I have done.
I have written a trigger with before insert and before update events.
Done all the bulkification.
and storing in Map.
Map<String,Map<String,Config__c>> mtfcMap = new Map<String,Map<String,Config__c>>();
for(Media_Type_Factor_Config__c mtfc : [
SELECT MType__c,
MFactor__c,
Product__c
FROM Config__c
WHERE Product__c IN :prodSet
AND MType__c IN : mediaTypeSet
]){
if(mtfcMap.get(mtfc.MType__c) == null){
mtfcMap.put(mtfc.MType__c, new Map<String, Config__c>{mtfc.Product__c => mtfc});
}
else{
mtfcMap.get(mtfc.MType__c).put(mtfc.product__c,mtfc);
}
}
//Now Processing all incoming opplineitem request
for(OpportunityLineItem oppli : Trigger.New){
//Here I have to use mtfcMap and write my logic
}
Any help???
Basically If it was a single map collection then I'd have done it, but here we are using Map inside Map so facing difficlty.