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
RJ12RJ12 

Trigger to Update a field in Parent object.

I'm trying to write a trigger to update a field in Parent record when Child record is created or updated.

Parent Object: Opportunity
Custom Field in Parent Object: Signed_by__c

Child Object: Invoice__c
Custom Field in Child object: Signed_by__c

Whenever the child record is saved (Inserted/updated), the value in 'Signed_by__c' field in child record must be copied to 'Signed_by__c' field in the parent record.

Suresh Kumar Arjunan1Suresh Kumar Arjunan1
I would suggest to try with cross object workflow field update or process builder approach instead of directly going into Apex (assuming not much apex code written in opportunity or custom object).

Also, you might need to consider scenario where multiple child record exists and which record field value needs to be updated in parent field as well.