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
nksfnksf 

Validation Rule Not Working

Hi Guys I need your help with a Validation Rule. It is very urgent. 
Here is my Validation Rule
AND(ISCHANGED(OwnerId), Account_Management_Account__c = True, $UserRole.Id <> "00E4000000184OK", $UserRole.Id <> "00E40000000tCwV", $UserRole.Id = "00E40000000tlQS", $User.ProfileId <> "00e40000000oz3O", $User.ProfileId <> "00e30000000cGQI")

I am trying that if Any user try to change the owner and if Account Management Account Checkbox Formula Field is True and if User Role and User Profile are not equal to ******* then give a Validation Error. 
I have tried this Validation Rule and it is not working. Account Management Account is Formula Checkbox Field (Is this could be reason?)
Thanks in advance. 
Best Answer chosen by nksf
nksfnksf
It worked this time.
AND(ISCHANGED(OwnerId), PRIORVALUE(Account_Management_Account__c) = True, $UserRole.Id <> "00E40000000tCwV", $UserRole.Id <> "00E40000000tlQS", $UserRole.Id <> "00E4000000184OK", $User.ProfileId <> "00e40000000oz3O", $User.ProfileId <> "00e30000000cGQI")

All Answers

Andy BoettcherAndy Boettcher
The best bet with any kind of formula troubleshooting is to take your formula down as small as possible first, get it working on one criteria, and then start adding criteria until you find the problem.

Iterate through your criteria like this - save the validation rule and save a record to verify if it works or not:
 
AND(ISCHANGED(OwnerId))

AND(ISCHANGED(OwnerId), Account_Management_Account__c = True)

AND(ISCHANGED(OwnerId), Account_Management_Account__c = True, $UserRole.Id <> "00E4000000184OK")

AND(ISCHANGED(OwnerId), Account_Management_Account__c = True, $UserRole.Id <> "00E4000000184OK", $UserRole.Id <> "00E40000000tCwV")

AND(ISCHANGED(OwnerId), Account_Management_Account__c = True, $UserRole.Id <> "00E4000000184OK", $UserRole.Id <> "00E40000000tCwV", $UserRole.Id = "00E40000000tlQS")

AND(ISCHANGED(OwnerId), Account_Management_Account__c = True, $UserRole.Id <> "00E4000000184OK", $UserRole.Id <> "00E40000000tCwV", $UserRole.Id = "00E40000000tlQS", $User.ProfileId <> "00e40000000oz3O")

AND(ISCHANGED(OwnerId), Account_Management_Account__c = True, $UserRole.Id <> "00E4000000184OK", $UserRole.Id <> "00E40000000tCwV", $UserRole.Id = "00E40000000tlQS", $User.ProfileId <> "00e40000000oz3O", $User.ProfileId <> "00e30000000cGQI")

 
nksfnksf
Thanks let me try this
nksfnksf
It worked this time.
AND(ISCHANGED(OwnerId), PRIORVALUE(Account_Management_Account__c) = True, $UserRole.Id <> "00E40000000tCwV", $UserRole.Id <> "00E40000000tlQS", $UserRole.Id <> "00E4000000184OK", $User.ProfileId <> "00e40000000oz3O", $User.ProfileId <> "00e30000000cGQI")
This was selected as the best answer