function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
KRaviKRavi 

Logical complication while using Map

I thought I’d share a logical complication am dealing with, as figuring this is kind of crushing me.
I have the below data in a map…..
while creating invoice for 120 quantity
First 100 qty should be charged for $20 each
Next 20 qty should be charged for $15 each
Invoice Total = (100 X 20) + (20 X 15) = $2300.
 
ItemDescriptionBilling UnitPrice Frequency of ThresholdStart Date of CalculationExpiration Date of Threshold  MinThreshold Max
Chem01LandDropDrum$20.00Yearly01/01/1712/31/171100
Chem01LandDropDrum$15.00 Yearly01/01/1712/31/17101150
Chem01LandDropDrum$10.00 Yearly01/01/1712/31/17151200
 
 
But Inside trigger, I couldn’t get the exact price ($15) for next 20 qty, as I do not have a proper unique key on Map…..couldn’t think of decent logic to get there. any thoughts would be appreciated.

Thanks
Kishore
Wilfredo Morillo 20Wilfredo Morillo 20
For(Integer i=0; i<Map.size();i++){
    
    If(i<=100){
        //change the price to 20.
    }Else If(i>100 &&i<=150){
    //change the price to 15.
    }Else If(i>100 &&i<=150){
     //change the price to
    }
}

**Using Map you cannot have duplicate keys.