Lock Down DLRS Fields and Make DLRS Play Nicely with Validation Rules

So you have a DLRS field and you don’t want your users to update the field as it should always be controlled by DLRS.  This can be taken care of via Field Level Security (FLS).  DLRS Runs in Apex and Apex runs in system mode meaning that it doesn’t care about FLS or anything like that.  This means you can set the field to Read-Only for all profiles and DLRS will still be able to update the field no matter what user triggers the DLRS.

The other bonus to this is you can easily set DLRS fields to bypass Validation Rules.  We now know that the DLRS field can ONLY be updated by a system process (Apex, Workflow Rule, Process Builder, Flow launched from Process Builder) so we can write the following into your validation rules.  NOT(ISCHANGED(DLRS_FIELD__C)), so say the field isnt changed we then end up with NOT(FALSE), this becomes TRUE so your Validation rule fires as it should.  But now when DLRS fires we end up with NOT(TRUE), this becomes False and the validation rule is bypassed so DLRS can keep doing its thing even to records that might be locked by validation rules.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.