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
Paula Jarvis 4Paula Jarvis 4 

Account Validation not working as composed

I have an Account Validation Rule that locks down a field on the Account. I did not enconter any Syntax errors so Ithought I as good to go until I started testing with a Profile not listed. Only the two Profiles listed should be able to enter AND edit the field referenced in the Rule. Any thoughts how to correct?

AND(
$Profile.Name = "Custom Billing Administrator",
$Profile.Name = "System Administrator",
ISCHANGED( RecurSoft__Billing_Contact__c )
)
Best Answer chosen by Paula Jarvis 4
Parker EdelmannParker Edelmann
Yes. Your current validation asks three questions:
  1. Is the user a Custom Billing Administrator? True or false.
  2. Is the user a System Administrator? True or False.
  3. Has the RecurSoft__Billing_Contact__c been changed? True or false.
If the answer is true for those three questions, the rule fires, but it will never fire because it's impossible for a user to have two profiles.
A slight tweak will fix the problem. Change the formula to this:
AND(
!OR(
$Profile.Name = "Custom Billing Administrator",
$Profile.Name = "System Administrator"),
ISCHANGED( RecurSoft__Billing_Contact__c )
)
Now it asks two questions:
  1. Does the user have a profile other than Custom Billing Administrator or a System Administrator? True or False.
  2. Has the RecurSoft__Billing_Contact__c been changed? True or false.
Take good note of the exclamation point, it works like the function NOT(). Because that is there, instead of firing when the user is one of the two profiles, It fires when it is not one of the two profiles. This should work as desired.

All Answers

Parker EdelmannParker Edelmann
Yes. Your current validation asks three questions:
  1. Is the user a Custom Billing Administrator? True or false.
  2. Is the user a System Administrator? True or False.
  3. Has the RecurSoft__Billing_Contact__c been changed? True or false.
If the answer is true for those three questions, the rule fires, but it will never fire because it's impossible for a user to have two profiles.
A slight tweak will fix the problem. Change the formula to this:
AND(
!OR(
$Profile.Name = "Custom Billing Administrator",
$Profile.Name = "System Administrator"),
ISCHANGED( RecurSoft__Billing_Contact__c )
)
Now it asks two questions:
  1. Does the user have a profile other than Custom Billing Administrator or a System Administrator? True or False.
  2. Has the RecurSoft__Billing_Contact__c been changed? True or false.
Take good note of the exclamation point, it works like the function NOT(). Because that is there, instead of firing when the user is one of the two profiles, It fires when it is not one of the two profiles. This should work as desired.
This was selected as the best answer
Parker EdelmannParker Edelmann
Glad it worked for you. Thanks for selecting it as best answer.