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
SFDC palaceSFDC palace 

HELP NEEDED! Validation Rule - AND/OR

I want to add a Validation Rule on an opportunity that ensures a custom field is completed when certain stages are selected.   This is simple enough and works like this
 
AND ( 
 OR (
    ISPICKVAL( StageName, "A - Pending Sale"),
    ISPICKVAL( StageName, "W - Closed Won")),
ISNULL(  Secured_Date__c  )
 
So give error message requiring Secured Date to be entered if stage = Pending or Won.
 
However,  I only want it to validate on a particular record type.   I'm not sure where the record type = statement goes in the formular, below does not work.
 
AND ( 
 OR (
    ISPICKVAL( StageName, "A - Pending Sale"),
    ISPICKVAL( StageName, "W - Closed Won")),
ISNULL(  Secured_Date__c  ),
RecordTypeId="01250000000DKQnAAO")
 
any suggestions would be greatly appreciated.
Best Answer chosen by Admin (Salesforce Developers) 
SFDC palaceSFDC palace

Eric

Thank you so much for your help.  Works perfectly.

Best Regards

All Answers

EricBEricB
The trick is to use the new $RecordType.Name variable.  See my example below.  Note that you should use the text value of your record type name, not the ID.

AND ( 
  OR (
     ISPICKVAL( StageName, "A - Pending Sale"),
     ISPICKVAL( StageName, "W - Closed Won")),
ISNULL(  Secured_Date__c  ),
$RecordType.Name = "record type name"
)

SFDC palaceSFDC palace

Eric

Thank you so much for your help.  Works perfectly.

Best Regards

This was selected as the best answer