function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Besides Validation rule, is there any other way to validate a field?

Besides Validation rule, is there any other way to validate a field?


I need to validate a field if it is empty, the field is visible for certain profile only.

E.g  hidden to Standard user profile

       visible to Marketing user profile



When a standard user login and create an account, even the field is hidden to them, validation rule is still check on the field if it is empty and return error.


Please advise. 


Thank you.

Richie DRichie D



You could have a trigger that fires before update/insert and checks the value there. If it has changed then validate it with some custom apex code. If validation fails then appen an error to that item. You will need to bulkify the trigger as it could be called as part of a batch update.


You may also be able to get the users profile and the permissions for that field to further extend that functionality. This may be dependent on the field level security and not whether or not it is added to the page layout.






when i use trigger to throw the error message, it returns an ugly system exception message. because the checking failed to make the record to insert/update. 


is there any other option?

It sounds like you might be better off making the field required on the page layout, rather than on the field itself.