You need to sign in to do that

Don't have an account?

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)

)

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)

)

Vinit_KumarMike,

Try below code :- If this helps,please mark it as best answer to help others.

## All Answers

Daniel B Probertput an iff at the beginning that refers to the RecordTypeId

if(RecordTypeId = 'sf code'), you code, null)

Mike FitchShould 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 Probertyes so what i meant is:

Mike FitchOk 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 Probertjust say don't do anything if the recordtypeid doesn't match.. Mike FitchOk that makes perfect sense now. Thank you so much for your help!!! Daniel B Probertno worries glad i could help.. Mike FitchI tried the code you suggested and I'm getting a syntax error saying there's an extra ',' after the IF statement. Vinit_KumarMike,

Try below code :- If this helps,please mark it as best answer to help others.

Daniel B Probertah yes missing ( at the beginning.. Mike FitchThat was it. I was missing that extra parenthesis after the IF. Thank you.