0

I'm new to validation rules and I'm trying to write one for a custom object that looks at a field called Status and once the picklist value is changed to "Complete", then no one can edit any field on that record, except for the $User.PrimarySystemAdministrator__c or $UserRole.Name = "Executive Director".

This is what I have so far, but when testing a user that doesn't have either of those criteria, I'm still able edit fields in the record, just not the status field.

AND(
ISPICKVAL(Status__c, "Complete"),
ISCHANGED(Status__c),
NOT(
    OR(
        $User.PrimarySystemAdministrator__c,
        $UserRole.Name = "Executive Director"
    )
  )
)

Something else to note though I don't think it's relevant.

I have a screen flow that creates a new record when run, however the status is by default set to "Draft". Since the default status isn't "Complete" I'm guessing this flow shouldn't be part of it.

5
  • You need to remove the ISCHANGED(Status__c) condition. If record needs be locked for edit after status is changed to Complete, there is no need to check for status changes.
    – Rohit
    Oct 25, 2023 at 5:04
  • I did try that with the below, however with it written this way, testing a user that doesn't have either of those criteria, I am still able to edit all fields except for "Status", even though non of the fields should be editable. In addition, there are two statuses in the picklist, "Complete" and "Draft". By default "Draft" is the status, but now I'm not even able to change the status from "Draft" to "Complete", I'm only able to change all other fields. AND( ISPICKVAL(Status__c, "Complete"), NOT( OR( $User.PrimarySystemAdministrator__c, $UserRole.Name = "Executive Director" ) ) )
    – DUser
    Oct 25, 2023 at 8:20
  • Got it. This question provides a solution for your requirement.
    – Rohit
    Oct 25, 2023 at 15:59
  • @cropredy : I had shared the same link above 😁
    – Rohit
    Oct 26, 2023 at 3:31
  • @rohit - I know, but I clicked Close and provided the link - this initiates the close process as a duplicate question
    – cropredy
    Oct 26, 2023 at 15:37

0

Browse other questions tagged .