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.
ShowAll Questionssorted byDate Posted Mike Fitch

# Assigning a Record Type to a Validation Rule

I created a validation rule on the opportunity object that limits the Probability % field to certain values. I need to make this rule active for a particular record type. I need help with the syntax in order to do this. Here is the formula:

OR(
AND(
ISPICKVAL(StageName,"Closed Lost"),
Probability <> 0),
AND(
MOD(Probability*100,10)<>0,
!ISPICKVAL(StageName,"Closed Lost"),
!ISPICKVAL(StageName,"Closed Won")
),
AND(
OR(
Probability = 0.5,
Probability = 0,
Probability = 1),
!ISPICKVAL(StageName,"Closed Lost"),
!ISPICKVAL(StageName,"Closed Won")
),
AND(
ISPICKVAL(StageName,"Closed Won"),
Probability <> 1)
) Best Answer chosen by Mike Fitch Vinit_Kumar
Mike,

Try below code :-
```If((RecordTypeId='<Id of RecordType>'),OR(
AND(
ISPICKVAL(StageName,"Closed Lost"),
Probability <> 0),
AND(
MOD(Probability*100,10)<>0,
!ISPICKVAL(StageName,"Closed Lost"),
!ISPICKVAL(StageName,"Closed Won")
),
AND(
OR(
Probability = 0.5,
Probability = 0,
Probability = 1),
!ISPICKVAL(StageName,"Closed Lost"),
!ISPICKVAL(StageName,"Closed Won")
),
AND(
ISPICKVAL(StageName,"Closed Won"),
Probability <> 1)
),null)``` Daniel B Probert
put an iff at the beginning that refers to the RecordTypeId

if(RecordTypeId = 'sf code'), you code, null) Mike Fitch
Should I put the IF statement at the very beginning before the OR statement? Also what did you mean by "you code, null)"? I apologize but I'm new to salesforce development. Daniel B Probert
yes so what i meant is:

```IF(RecordTypeID = 'sf code'),
OR(
AND(
ISPICKVAL(StageName,"Closed Lost"),
Probability <> 0),
AND(
MOD(Probability*100,10)<>0,
!ISPICKVAL(StageName,"Closed Lost"),
!ISPICKVAL(StageName,"Closed Won")
),
AND(
OR(
Probability = 0.5,
Probability = 0,
Probability = 1),
!ISPICKVAL(StageName,"Closed Lost"),
!ISPICKVAL(StageName,"Closed Won")
),
AND(
ISPICKVAL(StageName,"Closed Won"),
Probability <> 1)
), null)``` Mike Fitch
Ok I understand. May I ask what the null statement is for? I'm sure that's the proper syntax, I would just like to understand why it's needed. Like I said I'm fairly new to this :) Daniel B Probert
just say don't do anything if the recordtypeid doesn't match.. Mike Fitch
Ok that makes perfect sense now. Thank you so much for your help!!! Daniel B Probert
no worries glad i could help.. Mike Fitch
I tried the code you suggested and I'm getting a syntax error saying there's an extra ',' after the IF statement. Vinit_Kumar
Mike,

Try below code :-
```If((RecordTypeId='<Id of RecordType>'),OR(
AND(
ISPICKVAL(StageName,"Closed Lost"),
Probability <> 0),
AND(
MOD(Probability*100,10)<>0,
!ISPICKVAL(StageName,"Closed Lost"),
!ISPICKVAL(StageName,"Closed Won")
),
AND(
OR(
Probability = 0.5,
Probability = 0,
Probability = 1),
!ISPICKVAL(StageName,"Closed Lost"),
!ISPICKVAL(StageName,"Closed Won")
),
AND(
ISPICKVAL(StageName,"Closed Won"),
Probability <> 1)
),null)``` Daniel B Probert Mike Fitch