trigger CreatingCase on Bookings__c (after insert)
{
list<case> CaseList = new list<case>();
for(integer i=0;i<trigger.size;i++){
case c = new case();
c.Vehicles__c = trigger.new[i].Vehicle__c;
c.Zone_Value__c = trigger.new[i].Zone__c;
c.Booking_No__c = trigger.new[i].name;
// c.Booking__c = trigger.new[i].Id;
CaseList.add(c);
}
if(caseList.size()>0) {
insert CaseList; system.debug(CaseList);
}
}
The above code is simplified. I am not sure if you are wanting to link your cases to the booking object or not, but you would need a line of code like the above that is commented out.
You are needing to populate the Booking ID on the case object to have them linked together.
Sure, that can be done. You would want to create a After Insert trigger on the booking object.
All Answers
Sure, that can be done. You would want to create a After Insert trigger on the booking object.
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;
}
i can create a booking object but the case object is not created can i know what is the maitake in my code????
The above code is simplified. I am not sure if you are wanting to link your cases to the booking object or not, but you would need a line of code like the above that is commented out.
You are needing to populate the Booking ID on the case object to have them linked together.
Hope this helps.