You need to sign in to do that
Don't have an account?

Auto Populating Lookup Field from another Lookup Field
I am trying to auto populate a lookup field using an apex trigger and could use some help. My case only uses opportunity objects. On each opportunity there are 2 lookup fields. Example: Once lookup_field_A on Opp1 gets filled with Opp2, I would like to fill Opp2's lookup_field_B with Opp1.
I've started writing this code out but I'm unsure how to grab Opp2 from lookup_field_A and then set lookup_field_B to be Opp1.
Anyone have any ideas? Any insight would be helpful.
I've started writing this code out but I'm unsure how to grab Opp2 from lookup_field_A and then set lookup_field_B to be Opp1.
Anyone have any ideas? Any insight would be helpful.
New class
then try below code
All Answers
for (Opportunity o:Trigger.new)
if (o.Upcoming_Renewal_Opportunity__c != null)
Opportunity opp = [SELECT Id, Name, Upcoming_Renewal_Opportunity__c FROM Opportunity WHERE Id = :o.Id];
//opp.Previous_Renewal_Opportunity__c = Opportunity o;
//List<Opportunity> opportunities = new List<Opportunity>();
//opportunities.add(opp.opportunity__r);
//o.Previous_Renewal_Opportunity__c = o.Upcoming_Renewal_Opportunity__c;
}
Anything that is commented out, is something I've tried but was unsuccessful. Thank you for the response!!
New class
then try below code
So do I need to add a condition to that if statement?