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

Approval process : Lock child records



I have a custom object which has two child custom objects.  The relationship is Lookup, not Master-Detail.  These three objects are connected and can be viewed as a single part of a process.


I have an approval process on the parent object.  This locks the record.  However, the child records remain accessible.


Are there any methods that allow the automated locking of the child records off the back of the approval process on the parent?





I have a very similar requirement, unfortunately, I've not found a solution.


I'd like it if there were a "lock related records" option when setting up an approval process for the parent record. I've search for such a feature but haven't found one.


Here's what I came up with though.... I'm using Master-Detail in this example, but it would work with a lookup also.


I've added a checkbox field to the Master record, called Locked__c, and use the approval process to set this field to TRUE when it kicks off. The following trigger prevents any changes to the children while this Locked__c box is checked:


trigger DetailLockCheck on Detail__c (before delete, before insert, before update) {

     Set<Id> masterIdSet = new Set<Id>();

     for (Detail__c each :


     Map<String, Boolean> masterMap = new Map<String, Boolean>();


     for (Master__c each : [select Id, Locked__c from Master__c where Id in :masterIdSet])
          masterMap.put(each.Id, each.Locked__c);

     for (Detail__c each : {
          if (masterMap.get(each.Master__c))
               each.addError('Master Record is Locked. Details cannot be created, edited, or deleted.');



Does anyone have a more straight-forward way to accomplish this?