function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jpb@uhcjpb@uhc 

Cross Object Trigger Help (Opportunity & OpportunityLineItem)

We have matching picklist fields on both the Opportunity and OpportunityLineItem. I need to come up with a trigger that updates the Opportunity everytime the field is changed on the OpportunityLineItem. I have written basic triggers in the past, but the cross object stuff has me perplexed. Any help with some code to get me started would be much appreciated. Here are some details:

 

Field Name: Fee_Schedule__c (same on both objects)

 

I know that there could be multiple line items, but all line MUST have the same value in the Fee_Schedule__c field, so can we just use a select with the "limit 1" approach to get the value from the OpportunityLineItem records associated with the Opportunity?

spraetzspraetz

Jsut to make sure I'm understanding properly, you want it such that whenever all of the OppLineItems' Fee_Schedule__c field is equal to the same value tha the Opportunity's Fee_Schedule__c field is updated?

 

Or do you want it such that whenever the Opportunity.Fee_Schedule__c field is updated that it goes and updates all the OppLineItems' Fee_Schedule__c field?

jpb@uhcjpb@uhc

The first one...from OppLineItem.fee_schedule__c (when all the same) to Opportunity.fee_schedule__c