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
Patrick ChildersPatrick Childers 

Difficult Validation Rule

OBJECT A - CASE
OBJECT B - CUSTOM 
                3 Record Types ((A or B) and C)

After Case is created, I am trying to write a validation rule that will lock down all editting until two record types are related to the case ((A or B) and C)

I currently have this formula:
AND(
        $RecordType.DeveloperName = "Case_Record_Type",
        A_Rollup__c = 0, 
        B_Rollup__c = 0,
        C__c = 0,
        NOT(ISNEW())
)

I am using "The Power of One" and the "Rollup__c" fields are just number fields. 

This formula does exactly what I want it to do, other than only requires one of the three records to be related and then will unlock the Case record for editting. I need it to stay locked until the records related are (A and C) or (B and C)

 
Boss CoffeeBoss Coffee
Is C__c the rollup for the C record type?

You could try something like the following:
AND(
  $RecordType.DeveloperName = "Case_Record_Type",
  IF(
    C__c != 0,
    AND(A_Rollup__c = 0, B_Rollup__c = 0),
    TRUE
  ),
  NOT(ISNEW())
)
Boss CoffeeBoss Coffee
Actually, I believe the following should work as well:
AND(
  $RecordType.DeveloperName = "Case_Record_Type",
  OR(
    C__c = 0,
    AND(A_Rollup__c = 0, B_Rollup__c = 0)
  ),
  NOT(ISNEW())
)
Patrick ChildersPatrick Childers
I tried both of these. The problem I'm running into with these is that I cannot create a new related record from the related record list or an quick action buttons.
Patrick ChildersPatrick Childers
It also will not allow me to relate Object B records to Case from Object B
Boss CoffeeBoss Coffee
The reason why it wouldn't work earlier is because the rollup count change would be stopped by the validation rule. Try the following.
AND(
  $RecordType.DeveloperName = "Case_Record_Type",
  OR(
    C__c = 0,
    AND(A_Rollup__c = 0, B_Rollup__c = 0)
  ),
  IF(ISCHANGED(C__c), false, true),
  IF(ISCHANGED(A_Rollup__c), false, true),
  IF(ISCHANGED(B_Rollup__c), false, true),
  NOT(ISNEW())
)