<?xml version="1.0" encoding="UTF-8"?>
<ValidationRule xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>AWAL_ValidateCommittedRights</fullName>
    <active>true</active>
    <description>Blocks the user from removing values from the multi-picklist when these values are already approved by finance.</description>
    <errorConditionFormula>AND(
    RecordType.DeveloperName = &quot;AWAL&quot;,
    NOT($Permission.AWAL_Bypass_VRs),
    NOT(AND(Is_Migrated__c, OR(ISPICKVAL(Migrated_From_Opportunity__r.StageName, "Pass to Approver (KLS only)"), ISPICKVAL(Migrated_From_Opportunity__r.StageName, "Passed to Finance"), ISPICKVAL(Migrated_From_Opportunity__r.StageName, "Passed to BA")))),
    NOT(
        OR(
            ISPICKVAL(StageName, &quot;Deal Tracking&quot;),
            ISPICKVAL(StageName, &quot;Deal Discussions&quot;),
            ISPICKVAL(StageName, &quot;Passed to Finance&quot;),
            ISPICKVAL(StageName, &quot;Passed to Finance Approver&quot;),
            ISPICKVAL(StageName, &quot;Finance Analysis Complete&quot;),

            ISPICKVAL(PRIORVALUE(StageName), &quot;Deal Tracking&quot;),
            ISPICKVAL(PRIORVALUE(StageName), &quot;Deal Discussions&quot;),
            ISPICKVAL(PRIORVALUE(StageName), &quot;Passed to Finance&quot;),
            ISPICKVAL(PRIORVALUE(StageName), &quot;Passed to Finance Approver&quot;),
            ISPICKVAL(PRIORVALUE(StageName), &quot;Finance Analysis Complete&quot;)
        )
    ),
    OR(
        AND(
            INCLUDES(MaximumApprovedTerms__r.CommittedRights__c, &quot;Digital&quot;),
            NOT(INCLUDES(CommittedRights__c, &quot;Digital&quot;))
        ),
        AND(
            INCLUDES(MaximumApprovedTerms__r.CommittedRights__c, &quot;Physical&quot;),
            NOT(INCLUDES(CommittedRights__c, &quot;Physical&quot;))
        ),
        AND(
            INCLUDES(MaximumApprovedTerms__r.CommittedRights__c, &quot;Synch&quot;),
            NOT(INCLUDES(CommittedRights__c, &quot;Synch&quot;))
        )
    )
)</errorConditionFormula>
    <errorDisplayField>CommittedRights__c</errorDisplayField>
    <errorMessage>You cannot remove &quot;Digital&quot;, &quot;Physical&quot; or &quot;Synch&quot; values from Committed Rights when they are part of the approved terms.</errorMessage>
</ValidationRule>
