I can't seem to get my validation rule to work.

I need a Validation rule on user detail record to make phone number field required but only for certain profiles. I need the number to be in the format for UK numbers e.g 0207 456 7689 - must be 11 digit long and only required for anyone with any of the following profiles user detail record:

Profile Name = Sales Agent,
Profile Name = Field Sales Agent,
Profile Name = Field Service Agent,
Profile Name = Lead Gen Agent,
Profile Name = Leade Gen Team Leader/Manager,
Profile Name = Sales Team Leader/Manager
Profile Name = TEL Sales Agent,
Profile Name = THS Sales Agent

Any other profiles e.g system admin or standard user would be able to save the user detail record without phone number filed required.

I have tried this:

Profile.Name = "Sales Agent", 
OR(Profile.Name = ‘Field Sales Agent’),
OR(Profile.Name = ‘Field Service Agent’),
OR(Profile.Name = ‘Lead Gen Agent’),
OR(Profile.Name = ‘Lead Gen Team Leader/Manager’),
OR(Profile.Name = ‘Sales Team Leader/Manager’),
OR(Profile.Name = ‘TEL Sales Agent’),
OR(Profile.Name = ‘THS Sales Agent’)

Appreciate the help.


Hi, Thanks @Moonpie and @Caspar Harmer - that worked, appreciate it. I just now need to make sure the phone number always starts with 0 and is no more than 11 digits long as standard. This is what I have so far which hasn't worked:

!REGEX(Phone, "^(0)[1-9]{1}([0-9]{8,9})$"),
Phone != 'unknown',
OR (Profile.Name = "Sales Agent",
Profile.Name = "Field Sales Agent",
Profile.Name = "Field Service Agent",
Profile.Name = "Lead Gen Agent",
Profile.Name = "Lead Gen Team Leader/Manager",
Profile.Name = "Sales Team Leader/Manager",
Profile.Name = "TEL Sales Agent",
Profile.Name = "THS Sales Agent")

Would appreciate the help.


  • 4
    Welcome to Salesforce Stack Exchange (SFSE). Please edit your question to add the Validation Rule code which you have tried but that does not work.
    – Moonpie
    Commented Jul 20, 2021 at 17:42
  • It may just be a typo or transfer error, but the formula as posted is missing a , (comma) after ISBLANK(Phone).
    – Moonpie
    Commented Jul 21, 2021 at 1:09
  • If you would like to edit this question, you will need to recover the account you used to post it.
    – Adrian Larson
    Commented Jul 21, 2021 at 4:43

1 Answer 1


EDIT Added the phone part.

This is the syntax you'll need:

  Condition 1,
  OR (Condition 2,
      Condition 3,
      Condition 4)

In your case, it starts like this:

      NOT(REGEX(Phone, "^(0)[1-9]{1}([0-9]{8,9})$"))
   OR (Profile.Name = "Sales Agent",
       Profile.Name = "Field Sales Agent",
       Profile.Name = "Field Service Agent" 

The rule must fire IF:

  • The phone value is empty OR
  • The phone value is the wrong format AND
  • The profile is one of the following...

BTW, phone won't validate if 'unknown' so I don't think this is required.

Note how I've carefully formatted the functions - this makes it much easier to read and debug.

  • 1
    Since OR is the operator that the OP seems to be having the bigger issue with, I suggest you add the specific syntax for the OR similar to how you did for the AND.
    – Moonpie
    Commented Jul 21, 2021 at 1:05
  • Changed as per your suggestion - good idea! Commented Jul 21, 2021 at 1:11
  • @Caspar Harmer, thank you so much! That worked just need to now make it start with 0 and only 11 digits long. I've added what I have so far but doesn't quite work. Commented Jul 21, 2021 at 4:17
  • Thanks a lot @Moonpie! Commented Jul 21, 2021 at 4:19
  • 1
    @Caspar Harmer, worked! Thanks a lot! And yes, loved the formatting. Learnt a lot. Thanks for laying it out like that. Much appreciated. Commented Jul 21, 2021 at 19:02

You must log in to answer this question.

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