I want my VR to work when the field Department Mob'hy is not selected on two different record types. My VR shows no syntax error but still don't work.

OR (

AND ( ISBLANK( Departement_Mob_hy_Opp__c),
RecordType.Id = "01209000000EjLmAAK"),

AND (ISBLANK( Departement_Mob_hy_Opp__c),
RecordType.Id = "01209000000EjLSAA0")
  • 3
    are the Ids corrected? Do not use IDs, use DeveloperName. Ids could change when you deploy.
    – m Peixoto
    Aug 17 at 11:19
  • 1
    Try the 15-character long IDs instead of 18-character long ones. Even if that works, still think of a formula that does not use hard coded IDs. Aug 17 at 12:42

You're using the 18-digit Id, while validation rules don't support that (see this idea). It will support 15-digit Id, but as mentioned in the comment, avoid hard-coding your record type Id.

You can rely on DeveloperName of the record type. It's similar to the API name of a custom field, is unique, and gives you some benefits over the Id:

  • It will stay the same as you deploy through sandboxes and into production
  • Allows admins/users to easily change the label to meet business changes while not changing the API name and breaking this VR.
  • Is easier to understand what the VR is doing rather than seeing an Id which you do not know what it refers to.

You also don't need to repeat your ISBLANK and can move your OR() to simply contain either record type: this allows you to easily just add more record types as need be in the future.

        RecordType.DeveloperName = "YourRecordTypeDeveloperName"),
        RecordType.DeveloperName = "YourRecordTypeDeveloperName2")


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.