6

I have written a validation rule, which checks whether a certain picklist has a certain value. The reason for this is, when someone changes the record type of account, then the picklist has different values that are allowed for that record type, however we need a validation rule, because the user can save with an invalid value otherwise.

I have written the following, however nothing happens:

AND( 
$Profile.Name <> 'Admin', 
RecordType.DeveloperName = "New Accounts", 
NOT(ISPICKVAL(Stages__c ,"Stage 3")) 
)

Basically what I want to say here is that if the record type name is New Accounts, then fire the validation rule if stages is NOT set to Stage 3.

Tia, Lily.

2 Answers 2

7

DeveloperName is not the same as Name. It has special restrictions, much like API names (can't start with a number, no spaces or punctuation, etc). Check the Developer Name attribute of your record type. The formula editor won't throw an error, but you'll never match a DeveloperName to a string that contains spaces.

From the documentation:

Required. The unique name of the object in the API. This name can contain only underscores and alphanumeric characters, and must be unique in your organization. It must begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores.

0
1

For a validation rule, your formula should look like this:

IF(NOT((RecordType.DeveloperName = "API Name for Record Type Developer Name") && NOT(ISPICKVAL(Stages__c ,"Stage 3"))),True, False)

4
  • 4
    The IF(..., TRUE, FALSE) construct is never needed.
    – sfdcfox
    Commented May 18, 2016 at 13:22
  • She only wants the rule to fire when the stage is NOT set to Stage 3. I recognize that it can also be done using AND statements. She also wanted it the record type as well. This seemed like a more efficient way to me.
    – crmprogdev
    Commented May 18, 2016 at 13:33
  • 4
    @crmprogdev Independently of whether you prefer && over AND, you can drop IF(condition, true, false) to just condition and get the same Boolean output.
    – Adrian Larson
    Commented May 18, 2016 at 14:17
  • @AdrianLarson Thank you for the enlightenment! Will leave this here for others to learn from too. Otherwise I would delete.
    – crmprogdev
    Commented May 18, 2016 at 14:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .