You need to sign in to do that
Don't have an account?
harish reddy 39
Updateing field in before Insert Trigger..?
Hi,
I have 2 Custom objects(Reservations__c And HotelGusts__c) both objects have custom fields Email__c and have lookup from reservationsc to Hotelguests__c .Now i need to write a trigger which updates Reservations__c's Email Field with hotelguests__c's Email Field.Can any one help me with that.
Thanks in Advance.
My trigger Code:
trigger UpdateemailTrigger on Reservations__c (After insert) {
Reservations__c resv = New Reservations__c ();
List<Id> ids = New List<Id>();
for (Reservations__c hrs:trigger.new)
{
ids.add(hrs.HotelGuest__c);
}
List<Reservations__c> Revs1 = [Select Id ,Email__c from Reservations__c Where Id IN : ids];
HotelGuest__c Gust1 = New HotelGuest__c();
for (Reservations__c hrs:Revs1 )
{
hrs.Email__c = Gust1.Email__c;
Update Revs1 ;
}
I have 2 Custom objects(Reservations__c And HotelGusts__c) both objects have custom fields Email__c and have lookup from reservationsc to Hotelguests__c .Now i need to write a trigger which updates Reservations__c's Email Field with hotelguests__c's Email Field.Can any one help me with that.
Thanks in Advance.
My trigger Code:
trigger UpdateemailTrigger on Reservations__c (After insert) {
Reservations__c resv = New Reservations__c ();
List<Id> ids = New List<Id>();
for (Reservations__c hrs:trigger.new)
{
ids.add(hrs.HotelGuest__c);
}
List<Reservations__c> Revs1 = [Select Id ,Email__c from Reservations__c Where Id IN : ids];
HotelGuest__c Gust1 = New HotelGuest__c();
for (Reservations__c hrs:Revs1 )
{
hrs.Email__c = Gust1.Email__c;
Update Revs1 ;
}
You can do this via process builder.
Let's say one Reservations__c record has 5 HotelGusts__c records and all of these HotelGusts__c records has Email addres. Now. which email should updates Reservations__c's Email Field with hotelguests__c's Email Field?
Thanks for your reply
when ever hotelguest make a reservation email field in reservation__c should be updated with hotelguest email.
Trigger Code:
If it solves the query then please mark it as Best Answer since it will help other users as well!