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
SazEastSazEast 

Validation rule firing when it shouldn't

Hello,
Users are getting a validation error on records that are excluded from the validation rule. It should only fire for the three user profiles mentioned, and only fire if the approval status is set to 'Approved' if it was not already set to this. It also shouldn't fire if the record type is an invoice adjustment. Any ideas why this isn't working?
 
CONTAINS($Profile.Name, "Cash") ||
CONTAINS($Profile.Name, "RBC") ||
CONTAINS($Profile.Name, "Accounts Payable")


&&

ISPICKVAL(Approval_Status__c, "Approved")

&&

NOT(ISPICKVAL(PRIORVALUE(Approval_Status__c), "Approved") )

&&

RecordType.Name <> "Invoice_Adjustment"

Thanks
Best Answer chosen by SazEast
Danish HodaDanish Hoda
Hi,
Please try this:
AND(
    OR(
        $Profile.Name <> 'Cash',
        $Profile.Name <> 'RBC',
        $Profile.Name <> 'Accounts Payable'
    ),
    TEXT(Approval_Status__c) = 'Approved',
    TEXT(PRIORVALUE(Approval_Status__c)) = 'Approved',
    RecordType.Name <> "Invoice_Adjustment"
)

All Answers

Danish HodaDanish Hoda
Hi,
Please try this:
AND(
    OR(
        $Profile.Name <> 'Cash',
        $Profile.Name <> 'RBC',
        $Profile.Name <> 'Accounts Payable'
    ),
    TEXT(Approval_Status__c) = 'Approved',
    TEXT(PRIORVALUE(Approval_Status__c)) = 'Approved',
    RecordType.Name <> "Invoice_Adjustment"
)
This was selected as the best answer
SazEastSazEast
Thats worked, thanks Danish!