• saraaz
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 5
    Replies

this is my code i have done to create an case record whenever the booking record is created

But the case record is not created wen i create a booking record 

can anyone help mw out from this???

 

trigger CreatingCase on Bookings__c (after insert , after update) 
{
    set<id> BookingSet = new set<id>();
    for(integer i=0;i<trigger.size;i++)
        {
            BookingSet.add(trigger.new[i].id);
        }    
    list<case> CaseList = new list<case>();
    for(integer i=0;i<trigger.size;i++)
        {
            case caseinstance = new case();
            caseinstance.Vehicles__c = trigger.new[i].Vehicle__c;
            caseinstance.Zone_Value__c = trigger.new[i].Zone__c;
            caseinstance.Booking_No__c = trigger.new[i].name;
            CaseList.add(caseinstance);
        }
     insert CaseList;
}

  • September 13, 2013
  • Like
  • 0

Can we do this logic in trigger

   new record have to be created in case object whenever a booking__c object is created 

  • September 12, 2013
  • Like
  • 0

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

  • September 03, 2013
  • Like
  • 0

Hi i am getting error while executing the trigger so can any one help me out

 

ERROR MSG :· Compile Error: unexpected token: 'list' at line 8 column 47

 

Here is my trigger code

 

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 = list<Vehicle_Rental_Price__c>(); error in this line

                                 Vehicle_Rental_Price__c is not an custom object its an Custom setting which has a static values       
PriceOfVehicles = [select name , Rental_Price__c from Vehicle_Rental_Price__c where name in BookingModelSet];
Map<string , string> MappingPriceToModel = new Map<string , string>();
for(integer i=0;i<PriceOfVehicles.size();i++)
{
MappingPriceToModel.put(Vehicle_Rental_Price__c[i].name , Vehicle_Rental_Price__c[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);
}

}

 

  • August 31, 2013
  • Like
  • 0

this is my code i have done to create an case record whenever the booking record is created

But the case record is not created wen i create a booking record 

can anyone help mw out from this???

 

trigger CreatingCase on Bookings__c (after insert , after update) 
{
    set<id> BookingSet = new set<id>();
    for(integer i=0;i<trigger.size;i++)
        {
            BookingSet.add(trigger.new[i].id);
        }    
    list<case> CaseList = new list<case>();
    for(integer i=0;i<trigger.size;i++)
        {
            case caseinstance = new case();
            caseinstance.Vehicles__c = trigger.new[i].Vehicle__c;
            caseinstance.Zone_Value__c = trigger.new[i].Zone__c;
            caseinstance.Booking_No__c = trigger.new[i].name;
            CaseList.add(caseinstance);
        }
     insert CaseList;
}

  • September 13, 2013
  • Like
  • 0

Can we do this logic in trigger

   new record have to be created in case object whenever a booking__c object is created 

  • September 12, 2013
  • Like
  • 0

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

  • September 03, 2013
  • Like
  • 0

Hi i am getting error while executing the trigger so can any one help me out

 

ERROR MSG :· Compile Error: unexpected token: 'list' at line 8 column 47

 

Here is my trigger code

 

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 = list<Vehicle_Rental_Price__c>(); error in this line

                                 Vehicle_Rental_Price__c is not an custom object its an Custom setting which has a static values       
PriceOfVehicles = [select name , Rental_Price__c from Vehicle_Rental_Price__c where name in BookingModelSet];
Map<string , string> MappingPriceToModel = new Map<string , string>();
for(integer i=0;i<PriceOfVehicles.size();i++)
{
MappingPriceToModel.put(Vehicle_Rental_Price__c[i].name , Vehicle_Rental_Price__c[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);
}

}

 

  • August 31, 2013
  • Like
  • 0