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
Mike Lee 12Mike Lee 12 

Possible to query number of validation rules in use?

Hello,

I wanted to know if it's possible to query via the REST API the number of validation rules in use by an Object? We're starting a rollout of Salesforce Enterprise and from what I've read there is a limit of 100 validation rules for a single object. I'd like to programmatically setup a job on an external server that queries things like validation rules and if we approach some sort of threshold to email/alert out.

Thanks,

Mike
Best Answer chosen by Mike Lee 12
srlawr uksrlawr uk
Funny you should ask, I had a conversation about this sort of thing with someone recently, so I knew this post (see below) was out there.

For this you want to use what we all the MetaData API... its just a REST api, but connects you to the "configuration layer" - the meta data - of your org. All your custom objects, all your approval processes and yes, all your validations rules are in there, so you can start to build up queries over that info and do what you want with them.

Now this post uses the Metadata API from within an Apex page - but the example an be easily ported across to things like Java - or whatever you are a programmer in..

Here is the validation rules query bit:
https://developer.salesforce.com/forums/?id=906F0000000Ai6kIAC

 here is a little example of connecting to the metadata api from Java
https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_quickstart_java_sample.htm
(use the left nav to find tasty bits)

And here is what you can get about each validation rule:
https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_validationformulas.htm


post back if you have any luck? I would be interested to hear how this goes. :)

All Answers

srlawr uksrlawr uk
Funny you should ask, I had a conversation about this sort of thing with someone recently, so I knew this post (see below) was out there.

For this you want to use what we all the MetaData API... its just a REST api, but connects you to the "configuration layer" - the meta data - of your org. All your custom objects, all your approval processes and yes, all your validations rules are in there, so you can start to build up queries over that info and do what you want with them.

Now this post uses the Metadata API from within an Apex page - but the example an be easily ported across to things like Java - or whatever you are a programmer in..

Here is the validation rules query bit:
https://developer.salesforce.com/forums/?id=906F0000000Ai6kIAC

 here is a little example of connecting to the metadata api from Java
https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_quickstart_java_sample.htm
(use the left nav to find tasty bits)

And here is what you can get about each validation rule:
https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_validationformulas.htm


post back if you have any luck? I would be interested to hear how this goes. :)
This was selected as the best answer
Mike Lee 12Mike Lee 12
Thanks for the info! I'll give it a try and post what the results are.

Mike