Requirement is to use "Status" field in validation rule and "Status" is being used in two validation rule which is blocking each other when we activate both rules at a time.
Requirement - 1 User needs to change "Status" to Deactivated if prior value of "Status" was Draft or Pending Approval or Rejected.
Validation Rule - 1
AND(
NOT(OR(
PRIORVALUE(Status__c) = 'Draft',
PRIORVALUE(Status__c) = 'Pending Approval',
PRIORVALUE(Status__c) = 'Rejected'
)),
TEXT(Status__c) <> 'Deactivated'
)
Above solution is working perfect only when we have only this rule is Activated.
Requirement - 2 Status, Status Category, Start Date, End Date fields.
User needs to change "Status" to Blocked if prior value of "Status" was Approved and "Status Category" was Request or if prior value of "Status" was Saturated and "Status Category" was Expired and Today's date is falling in between "Start Date" & "End Date".
Validation Rule - 2
AND(
NOT(AND(
AND(Start_Date__c <= TODAY(), End_Date__c >= TODAY()),
OR(
TEXT(Status_Category__c) = 'Request',
TEXT(Status_Category__c) = 'Expired'
),
OR(
PRIORVALUE(Status__c) = 'Approved',
PRIORVALUE(Status__c) = 'Saturated'
)
)),
TEXT(Status__c) <> 'Blocked'
)
Again the above solution is working perfect only when we have only this rule is Activated.
Problem Now the problem arise when we activate both rules in system or else we combine both rules in a single rule.
If Requirement - 1 is satisfied in system then no need to check Requirement - 2. I am looking for a solution like this - If(Requirement -1, true, Requirement - 2).
Below is the Single Validation rule in which i have combined both Requirement - 1 & 2 into single rule.
OR(
AND(
NOT(OR(
PRIORVALUE(Status__c) = 'Draft',
PRIORVALUE(Status__c) = 'Pending Approval',
PRIORVALUE(Status__c) = 'Rejected'
)),
TEXT(Status__c) <> 'Deactivated'
),
AND(
NOT(AND(
AND(Start_Date__c <= TODAY(), End_Date__c >= TODAY()),
OR(
TEXT(Status_Category__c) = 'Request',
TEXT(Status_Category__c) = 'Expired'
),
OR(
PRIORVALUE(Status__c) = 'Approved',
PRIORVALUE(Status__c) = 'Saturated'
)
)),
TEXT(Status__c) <> 'Blocked'
)
)
In general salesforce doesn't recommend If Else or nest If Else in to be used in validation rule.
Looking for some suggestions.