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

Validation rule



How to find validation rules on Sobject. through apex code.


Validation rule:





Imran MohammedImran Mohammed

As much as i know, we cannot find validation rules written on SObjects.

But you can still see if anyone answers positive on that.

Even i would like to know if there is a way to find that.


It is technically possible through Apex Code, but the time involved would likely far exceed the benefits. You would have to create a custom call-out class to invoke the metadata API. Assuming you did so, the results would be part of the objects/ branch in the return set. In all honesty, it would probably be best to implement this as a third-party service (i.e. invoke a third-party server that then queries the API and returns results). This would lessen the probability of governor limits being reached if implemented in a reasonable protocol.