Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
ShowAll Questionssorted byDate Posted
KRavi

# 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.

 Item Description Billing Unit Price Frequency of Threshold Start Date of Calculation Expiration Date of Threshold  Min Threshold Max Chem01 LandDrop Drum \$20.00 Yearly 01/01/17 12/31/17 1 100 Chem01 LandDrop Drum \$15.00 Yearly 01/01/17 12/31/17 101 150 Chem01 LandDrop Drum \$10.00 Yearly 01/01/17 12/31/17 151 200

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 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.