The Expiry Date validation rule:
OR(
ISNEW()&& Expiry_Date__c >TODAY() + 182,
ISCHANGED(Expiry_Date__c) && NOT(ISCHANGED( Partner__c))
|| NOT(PRIORVALUE(Expiry_Date__c) <TODAY() - 182))
In plain English: the Expiry Date must be within the next six months.
To change or extend the Expiry Date, either it must be within the past six months, or the Partner must also be changed. Additionally, it can´t be changed to a date in the past.
The idea is that the date must be set while the record is new, and can only be changed if that date passes, or if the Partner is changed altogether.
If the Partner is changed, or the Expiry Date passes (and is within the past six months), then the Expiry Date should be extendable/changeable.
Which brings us to the Extension Expiry Date validation rule:
AND(
NOT(ISNEW()),
NOT(ISCHANGED( Partner__c)),
PRIORVALUE(Expiry_Date__c) < TODAY() - 182,
Expiry_Date__c >TODAY() + 91
|| Expiry_Date__c <TODAY())
If the record isn´t new, the Partner isn´t changed and the Expiry Date has been passed (and is within the past six months), then the Extension Expiry Date must be within the next three months, and can´t be changed to a date in the past either.
Now I have a Expiry Date: 12/12/2016 (a date that is within the past six months).
When I try to change it to 12/03/2017 (expecting the change to be successful), the error message for the first validation rule (the six-month rule) appears.
I´m not sure whether my logic is completely wrong, or I´m writing the "within the past six months" lines incorrectly - any ideas?