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
Laura GilLaura Gil 

What is wrong with the following Validation Rule for the Case object?

I am trying to let the following validation rule work:
 
AND(
AND($User.vub_Bypass_Validation_Rules__c = false, $Profile.Name = 'Profile A'),
OR(AND(OR(ISCHANGED(CaseOwner), ISCHANGED(ContactName), ISCHANGED(Status), ISCHANGED(Internal Comments)),
))
Unfortunately the syntax is not correct.
What I want is to prevent users with the Profile A (for example) to change/edit the standard fields Case Owner, Contact Name (lookup), Status and Internal Comments.

You can not set such fields as read only on page layout level. Users with this profile should be able to edit when Cases are of Record Type "Claim", but not cases of type "Only Information". So I see the only way is with a validation rule.

I would appreciate any help.
 
SabrentSabrent
// You have a spurious character, a comma after ISCHANGED(Internal Comments)),
// remove the comma
// Also why do you have OR(AND(OR
// just OR should suffice

// Try this 

AND(

AND($User.vub_Bypass_Validation_Rules__c = false, $Profile.Name = 'Profile A'), OR(ISCHANGED(CaseOwner), ISCHANGED(ContactName), ISCHANGED(Status),      ISCHANGED(Internal Comments))

)

 
VinayVinay (Salesforce Developers) 
Hi Laura,

Try below validation rule
 
AND($User.vub_Bypass_Validation_Rules__c= false, $Profile.Name = 'Profile A',OR(ISCHANGED(OwnerId), ISCHANGED(ContactId), ISCHANGED(Status)))

You cannot use "Internal Comments" in validation rule.  Review and vote for below idea link.

https://trailblazer.salesforce.com/ideaView?id=08730000000LjWrAAK

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Vinay Kumar
 
Andrew GAndrew G
as noted, the extra comma was the syntax error.  Also your extra use of AND and ORs made it difficult to read. 
I find that formatting formulas makes it easier to read the logic and find syntax errors
for example, the simplified Formula
 
AND( 
  $User.vub_Bypass_Validation_Rules__c = false, 
  $Profile.Name = 'Profile A',
  OR( 
    ISCHANGED(CaseOwner), 
    ISCHANGED(ContactName), 
    ISCHANGED(Status)
  )
)


And as noted, Internal Comments and ISCHANGED don't play well together.

Regards
Andrew