Error messages in Salesforce validation rules have a lot of responsibility. They are not just supposed to indicate what went wrong, but be specific about why, and mention what to do about it.

For example, let’s say if “Reason Code” (which is a picklist) has a value of “Other”, then the field “Reason Code Other” (which is text) is required.

To start, the error message could say, “This field is required”. While this message may be sufficient when a user is manually entering data into Salesforce, it certainly doesn’t offer enough details to someone importing data into the system. The same applies if the update is handled by an integration layer.

So a better message is, “Reason Code Other is required”. This is more helpful across all channels.

Further, following Nielsen Norman Group’s article on error message guidelines,

  • Error messages should explain the problem and a possible solution.
  • Error messages should be displayed close to the error’s source. In our example, this means displaying the error next to the field that caused the error, not the top of the page.

So the resulting error message is, “Reason Code Other is required when Reason Code is ‘Other'”. This message should be displayed next to the “Reason Code Other” field so the user knows which field to update.

The takeaway
Make sure validation error messages are:
1. Precise
2. Concise
3. Close to the error
4. Helpful to the user

Category:
Salesforce