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
TrickTrick 

Validation Rule

Hi Friends,

 

 

I have to understand some existing validation rule which I need to modify and then use it again.Can somebody please help me in understanding this rule.

 

Rule is given below:-

 

IF( 
AND( 
(ISPICKVAL(Channel_Opportunity__c ,"Direct")),
Not(ISPICKVAL( StageName ,"Identified")), 
$RecordType.Id ="0127000005ELJ",
$User.ProfileId <>"00e700000wujI"), 
ISPICKVAL( Bid_Strategy__c,"" ) 
,false)

 

 

Can u please explain what this validation rule seems to be doing and what is the role of $RecordType.ID and  $User.ProfileId and why are we using them.Please help.I know I am asking a bit too much but I also know that people in this forum have high calibre.

 

Trick

 

thomastthomast

I'm not sure what the IF() wrapper is trying to accomplish here; it's not really doing anything besides making the rule more confusing than it needs to be. You can think of Validation Rules as ALWAYS wrapped in an IF():

IF(

[Your VR Formula],

Not Valid - show error message,

Valid - save record)

 

So, this is functionally equivalent:

 

AND( 
    (ISPICKVAL(Channel_Opportunity__c ,"Direct")),
    Not(ISPICKVAL( StageName ,"Identified")), 
    $RecordType.Id ="0127000005ELJ",
    $User.ProfileId <>"00e700000wujI", 
    ISPICKVAL( Bid_Strategy__c,"" )
)

 

In any case, the $RecordType.Id is used tp make it so that this rule only applies to a certain record type. $User.ProfileId <> to a value exempts members of a certain Profile from the validation rule - maybe it's Admins, maybe it's Area Managers. For the User Profile, you can see which one it is by putting it at the end of your Salesforce instance URL, eg,

https://na2.salesforce.com/00e700000wujI. For record types, you'll have to go in to the record type list for the object. 

 

One more thing - as you posted it, both of those Ids are only 13 characters long, and Salesforce IDs are 15 characters. You may have edited the IDs for privacy, in which case stop reading now. If your rule really looks exactly as you posted it, then it will never fire, because the $RecordType.ID condition will never be true. If you fix that, then the $User.ProfileId will never be false, and no profiles will be able to bypass the validation.

 

-thomas