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
WPCMSWPCMS 

Validation: Profile Name

I am trying to exclude profiles from validations.

 

When I exclude System Administrator it works

 

Start_Date__c >=  Vendor_Location__r.Cancellation_Date__c&& $Profile.Name <> "System Administrator"

 

But when I add on Accounts Receivabled it doesn't work even though I spelled it the same and copied and pasted it

 

Start_Date__c >=  Vendor_Location__r.Cancellation_Date__c&&  $Profile.Name <> "Accounts Receivable"

 

What am I missing here!

 

Thank you in advance

Best Answer chosen by Admin (Salesforce Developers) 
MickleMickle

Change the || linking the two statements to be && and it should work. Also you could probably clean up that formula to be all on one line using parenthesis.

 

What your formula is stating is:

 

1.) Blahblahblah AND Profile can't be System Administrator

OR

2.) Blahblahblah AND Profile can't be Accounts Receivable

 

 

Therefore, if the profile is Sys Admin, the first statement is false, but the second statement is true, so the formula still evaluates to true, causing the error message to appear.

All Answers

WPCMSWPCMS

Actually I just realised it is when I put the whole code together it doesn't work

 

Start_Date__c >=  Vendor_Location__r.Cancellation_Date__c&& $Profile.Name <> "System Administrator"||
Start_Date__c >=  Vendor_Location__r.Cancellation_Date__c&&  $Profile.Name <> "Accounts Receivable"

MickleMickle

Change the || linking the two statements to be && and it should work. Also you could probably clean up that formula to be all on one line using parenthesis.

 

What your formula is stating is:

 

1.) Blahblahblah AND Profile can't be System Administrator

OR

2.) Blahblahblah AND Profile can't be Accounts Receivable

 

 

Therefore, if the profile is Sys Admin, the first statement is false, but the second statement is true, so the formula still evaluates to true, causing the error message to appear.

This was selected as the best answer
WPCMSWPCMS

yes, good ol' descrite mathematics!

 

Thanks!