I want to check the null validation using validation rules. I have 5 fields .

Field A ---> Phone field
Field B ----> Phone field
Field C ----> Text
Field D -----> Text
Field E ----> Email

It should throw error if any one of the fields have null. Please provide me a solution. Thanks in advance !!!

  • Can I ask why does it need to be a validation rule? A validation rule to check that a field is non-null is conceptually the same as making it required. It could be argued that the 'required' flag is the best solution for this, as it makes the intent more clear than a validation rule.
    – mkorman
    Jan 11 '16 at 11:27

The easiest way to do this is to declare all those custom fields as required in your object. You won't be able to save records if any of the fields are missing (both interactively or via code). This should do the job for you.

Edit: if you absolutely must use a validation rule, then add a validation rule to each individual field ensuring that an error is raised if the field is null. This will automatically make it so that if any of the fields is null the record won't be saved. I don't encourage this approach though.

  • that I know but I am not to supposed to create any layout. It has to be done through validation rule only. that is requirement
    – user27537
    Jan 11 '16 at 11:07
  • 1
    I have modified my answer. The 'required' field applies not just to layouts (ie: interactive saving), but also to saving programmatically via code.
    – mkorman
    Jan 11 '16 at 11:26

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.