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

Trigger a field update on a child record



I'm trying to create a checklist in salesforce that updates automatically.


A brief example - I have a Master-Detail Relationship between two objects: Program Intake (Master) and Client Checklist (Detail).  The API for the Program Intake field on the Client Checklist object is Program_Intake__c.


The Client Checklist has a checkbox called Service Plan (Service_Plan__c). 


There is also a Master-Detail Relationship between Program Intake (Master) and Service Plan (Detail). I then have a rollup summary on the Program Intake counting the # of Service Plans (PI_Service_Plan__c).


I want when PI_Service_Plan__c on the Program Intake is greater than 0 (basically, when a Service Plan record has been created), the checkbox Service_Plan__c on the Client Checklist is automatically checked.


I tried to do this via a workflow field update, but it doesn't work since I'm technically not editing the Client Checklist record. I essentially don't want the user to ever have to "Edit" this record. I have a feeling a trigger is needed, but I'm not all that adept at writing triggers. 


Is this a quick and easy trigger someone can write up? I've scoured the boards but haven't successfully copied anything yet.