[SalesForce] required field only for some users

I have a required field that only needs to be required for some users. (not all)
At this time, I have written a validation rule that will only do the validation for the users that I want.

The problem however is that when users are creating / editing the record, there is no red bar showing next to my field. It is only when saving that the user will be presented with the validation rule error.

How can I get the red mark to show on the edit page for the users where the field needs to be required?

Best Answer

This isn't possible on standard pages using validation rules - the red "required" marker is only displayed when a field is required, either at the page layout or field level. A validation rule will mark the field when the error occurs, but this is after the user attempts to save.

You can do this in Visualforce, by conditionally rendering some additional classes, but that would mean (a) moving your whole page to Visualforce and (b) having some of your logic in the validation rule (the actual rule) and some in the page (the knowledge about whether to display the field as required to a particular user).

If your rule was specific to a profile rather than a user, you could have a different page layout for each profile and make the field required (or not) at the page level.

Related Topic