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
Mdglover5Mdglover5 

Trigger: updating a related object

Hi all,

Looking to write a trigger, but i dont really know where to start!
I have an object called AffordabilityResults__c which has a lookup to the opportunity object. I need to update a field on the opportunity called PSDIncome__c with the value from the TotalGrossIncome__c on the AffordabilityResults__c object each time an affordability results record is created or updated. Any ideas where to start?

Thanks

Matt
Sonam_SFDCSonam_SFDC
You should create an after insert/after update trigger on AffordabilityResults__c and pull in the opportunity field PSDIncome__c using SOQL and name of the opportunity entered in AffordabilityResults__c  when inserting/updating and overwrite its value with the value entered in TotalGrossIncome__c field on  AffordabilityResults__c

Read sample code on: https://developer.salesforce.com/forums?id=906F0000000942RIAQ