You need to sign in to do that
Don't have an account?
Liz Malman
Auto Populating a field from two different objects
Hi all,
I have two object: Events and Opportunities. What I would like to have happen is the following:
When the field Engineer__c is filled out on an Opportunity, I would like for the related Events field Client_Services__c field to be filled out with the same content.
I know this will most likey be done with an Apex Trigger but I need some help with the code. In the past I have successfully done something similar but they were both the same object type. It seems the two different object types make it more complicated.
Any insight would be appreciated.
Thanks,
Liz
I have two object: Events and Opportunities. What I would like to have happen is the following:
When the field Engineer__c is filled out on an Opportunity, I would like for the related Events field Client_Services__c field to be filled out with the same content.
I know this will most likey be done with an Apex Trigger but I need some help with the code. In the past I have successfully done something similar but they were both the same object type. It seems the two different object types make it more complicated.
Any insight would be appreciated.
Thanks,
Liz
All Answers
trigger ClientServicesEventsTrigger on Opportunity (before insert) {
list<Events__c> EvtsToUpdate = new list<Events__c>();
for (Opportunity o:Trigger.new){
if (o.Engineer__c != null && !checkRecursive.SetOfIDs.contains(o.Id)){
Events__c evt = new Events__c();
evt.Id = o.Events__c;
evt.Client_Services__c = o.Engineer__c;
EvtsToUpdate.add(evt);
}
}
if(EvtsToUpdate.size() > 0){
update EvtsToUpdate;
}
Liz