You need to sign in to do that
Don't have an account?
Mariana D'Abreu
Query Validation Rules associated with an Object using REST API
I need to retrieve all the validation rules associated with a given object, using the REST API.
Looking in doc/forums, I've found that I could retrieve validation rules associated with an object using the following query:
https:///services/data/v35.0/tooling/query?q=Select Id,Active,Description,ErrorDisplayField, ErrorMessage From ValidationRule Where EntityDefinitionId = 'xxxxx'
The problem is that I don't have the object'ID needed to filter, I only have its name. Is there any way to filter using the object's name?
Another alternative seems to be getting the object'ID, but it seems that Metadata REST API (i.e. describe) does not return it.
Any help on this is very appreciated.
Mariana
Looking in doc/forums, I've found that I could retrieve validation rules associated with an object using the following query:
https:///services/data/v35.0/tooling/query?q=Select Id,Active,Description,ErrorDisplayField, ErrorMessage From ValidationRule Where EntityDefinitionId = 'xxxxx'
The problem is that I don't have the object'ID needed to filter, I only have its name. Is there any way to filter using the object's name?
Another alternative seems to be getting the object'ID, but it seems that Metadata REST API (i.e. describe) does not return it.
Any help on this is very appreciated.
Mariana
I did find that the developer name for custom objects were not what I expected, so you might want to verify the value by not having your where first.
All Answers
I did find that the developer name for custom objects were not what I expected, so you might want to verify the value by not having your where first.
Based on your answer, I finally used the following filter:
/services/data/v35.0/tooling/query?q=
Select Id,Active,Description,ErrorDisplayField, ErrorMessage From ValidationRule Where EntityDefinition.QualifiedApiName = 'SVMXC__Parts_Request__c'
Thank you very much!
[1] https://github.com/afawcett/apex-toolingapi/tree/apex-toolingapi-rest
[1] https://andyinthecloud.com/2014/01/05/querying-custom-object-and-field-ids-via-tooling-api/
[2] https://andyinthecloud.com/2014/03/17/going-native-with-the-apex-uml-tool-and-tooling-api/
[3] https://trailhead.salesforce.com/modules/apex_integration_services/units/apex_integration_rest_callouts
Hey pcon,
How can I retrieve 'errorConditionFormula' of ValidationRule?
I have total 3 ValidationRules for `Position__c` object, but 0 results were returned.I tried following code in workbench.