You need to sign in to do that
Don't have an account?
can we add elements in map
Hi i have jst added a prog in this i want to add the elements is this possible or not can any one help
trigger GettingPrice on Bookings__c (before insert , before update)
{
set<string> BookingModelSet = new set<string>();
for(integer i=0;i<trigger.size;i++)
{
BookingModelSet.add(trigger.new[i].Model__c);
}
list<Vehicle_Rental_Price__c> PriceOfVehicles = new list<Vehicle_Rental_Price__c>();
PriceOfVehicles = [select name , Rental_Price__c from Vehicle_Rental_Price__c where name in:BookingModelSet];
Map<string,decimal> MappingPriceToModel = new Map<string , decimal>();
for(integer i=0;i<PriceOfVehicles.size();i++)
{
MappingPriceToModel.put(PriceOfVehicles[i].name , PriceOfVehicles[i].Rental_Price__c);
}
for(integer i=0 ; i<trigger.size ; i++)
{
if(MappingPriceToModel.containskey(trigger.new[i].Model__c))
trigger.new[i].price_per_day__C = MappingPriceToModel.get(trigger.new[i].model__c);
}
}
in this the model__c is a multi picklist field so wen i select a single value from model the price_per_day is automatically generated but in case of selecting multiple values from Model__C the price_per_day is empty ???
can we add such type of values????
Like this?
thank you