Comments (4)
Can you share a snippet of Apex code that reproduces this please, i'll take a look. Thanks.
from apex-toolingapi.
Here is the snippet of code that gives me the error:
ToolingApi toolingApi = new ToolingApi();
ToolingAPIWSDL.QueryResult qr = toolingApi.query('SELECT Fullname, metadata, entitydefinition FROM ValidationRule WHERE EntityDefinition.QualifiedApiName=\'Account\'','ToolingAPIWSDL.ValidationRule');
from apex-toolingapi.
I've spent some time trying to get this working... ValidationRules need to be queried via a sub-select query while querying EntityDefinition. So the following query does return the response needed....
ToolingApi toolingApi = new ToolingApi();
ToolingAPIWSDL.QueryResult entityQueryResult =
toolingApi.query('SELECT Id, (Select Id from ValidationRules) FROM EntityDefinition Where QualifiedApiName=\'Test__c\'', 'ToolingAPIWSDL.EntityDefinition');
Problem with Apex Wrapper
However the logic in the Apex wrapper here does not support deserialising ValidationRules it appears. So a new exception is thrown when the wrapper attempts to deserialise the response. I need to take a longer look at the architecture of this wrapper to see if this is just a missing configuration or if this type of structure is a wider issue.
Workaround via Apex HTTP Callout
In the meantime you can using the Apex HTTP callout API and build the XML request as follows and parse via Apex XML API the response manually. The following is the XML request and response i captured.
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Header>
<SessionHeader xmlns="urn:tooling.soap.sforce.com">
<sessionId>[yoursessionidhere]</sessionId>
</SessionHeader>
</env:Header>
<env:Body>
<query xmlns="urn:tooling.soap.sforce.com">
<queryString>SELECT Id, (Select Id, Metadata from ValidationRules) FROM EntityDefinition Where QualifiedApiName='Test__c'</queryString>
</query>
</env:Body>
</env:Envelope>
Example XML response...
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:tooling.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mns="urn:metadata.tooling.soap.sforce.com">
<soapenv:Body>
<queryResponse>
<result>
<done>true</done>
<entityTypeName>EntityDefinition</entityTypeName>
<queryLocator xsi:nil="true"/>
<records xsi:type="EntityDefinition">
<Id>000000000000000AAA</Id>
<ValidationRules>
<done>true</done>
<entityTypeName>ValidationRule</entityTypeName>
<queryLocator xsi:nil="true"/>
<records xsi:type="ValidationRule">
<Id>03d58000000KbpgAAC</Id>
<Metadata>
<mns:active>true</mns:active>
<mns:errorConditionFormula>TRUE</mns:errorConditionFormula>
<mns:errorMessage>Test</mns:errorMessage>
</Metadata>
</records>
<size>1</size>
<totalSize>1</totalSize>
</ValidationRules>
</records>
<size>1</size>
<totalSize>1</totalSize>
</result>
</queryResponse>
</soapenv:Body>
</soapenv:Envelope>
from apex-toolingapi.
cc @dancinllama thoughts on this one?
from apex-toolingapi.
Related Issues (20)
- Port old ToolingAPIDemo.cls to new SOAP Edition HOT 3
- Should we rename project branches to clearly show type? HOT 2
- Retrieving only 2000 custom fields HOT 2
- Unable to cast ApexClass into sobject_x when calling the create method. HOT 4
- Unable to get the type of List/Set/Map added as parameter to a method HOT 1
- Unable to QUERY ValidationRule, throws GACK error HOT 3
- Invalid conversion from runtime type List<ToolingAPIWSDL.sObject_x> to List<ToolingAPIWSDL.CustomObject> HOT 2
- Create Call INVALID_TYPE: Must send a concrete entity type HOT 8
- Question: retrieving metadata from HOT 2
- Error getting retrieving metadata on FieldDefinition HOT 1
- Getting Error HOT 2
- References of methods from Symbol Table = null HOT 3
- REST: Type of properties or variables in ApexClass.SymbolTable always null HOT 4
- showing that ToolingAPI.CustomObjects is an invalid type. HOT 8
- Getting WorkflowOutboundMessage Id HOT 1
- Tests fail only during package upload - "CalloutException uncommitted work pending HOT 1
- Fetch workflow rules and validation rules
- WSDL question HOT 2
- Fetching Health Check Score and RiskTypes from the Org into the Code
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apex-toolingapi.