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
Bryan Revelant 7Bryan Revelant 7 

Trigger on parent to update Child record if parent = value

Hello, 

Was hoping for a bit of help with the below parent child trigger

Parent is ADR
CHILD is ADRUser

The below trigger works but, I want add some additional logic. If parent record Next_Step__c = submit then update the child ADRUser__c = Submit else do nothing. 

My SOQL is on the child record and my trigger on the parent. 

Help on the below?



trigger ADRParentUpdateChild on ADR__c ( after update, after insert) {
List<ADRUser__c > childRecords = [Select ADR__c, Status__c FROM ADRUser__c WHERE ADR__c IN :Trigger.newMap.keySet()];
        for(ADRUser__c child :childRecords){
            if(child.Status__c == null){
                child.Status__c = 'Submit';
            }
        if(childRecords.size() > 0)
            update childRecords;
}
Ramu_SFDCRamu_SFDC
Hi, I assume you are looking out for a way where you want this trigger to execute only on one particular field change and not on others. The below post might help

http://stackoverflow.com/questions/8671504/fire-a-update-trigger-when-particular-field-is-updated
Bryan Revelant 7Bryan Revelant 7
If a parent value = some string update all child records with that value. Not really at a granular level