afawcett / apex-toolingapi

Apex wrapper for the Salesforce Tooling API
BSD 3-Clause "New" or "Revised" License
134 stars 98 forks source link

Question: retrieving metadata from #40

Closed sierra82 closed 8 years ago

sierra82 commented 8 years ago

Hello, I may be at the wrong place to ask that but I found none other!

I'm an intern working on salesforce and I'm trying to create a Documentation generator in apex, so I installed this tool, wich alllows me to get all the metadata I need through the tooling API. BUT I'm trying to figure out how to retrieve the metadata for Validation rules (among other things) of a specific object, and I can't seem to figure out how to do that properly.

Here's how I tried to do that:

ToolingApi toolingApi = new ToolingApi();
ToolingAPIWSDL.QueryResult qr = toolingApi.query('Select Id, metadata From ValidationRule','ToolingAPIWSDL.ValidationRule');
for(ToolingAPIWSDL.ValidationRule vr : (List<ToolingAPIWSDL.ValidationRule>)qr.records){
    System.debug(vr.metadata);
}

I run that in anonymous in the developper console and it gives me this error:

Line: 4627, Column: 1
System.CalloutException: Web service callout failed: Unable to parse callout response. Apex type not found for element active

I'm probably using it wrong, but I've been stuck on this for two days and this seem like the perfect solution to my needs so if you can help me out, or even just point me to the documentation or example I've been looking for I'd be the happiest salesforce developper !

Thanks in advance :)

afawcett commented 8 years ago

This looks like a bug in the wrapper class ToolingAPIWSDL.ValidationRule. It's members should resemble the XML elements specified in the ValidationRule type as specified in the Tooling API WSDL file. Its missing the 'active' element and by the looks of it a few others looking at the docs, hence the error your getting.

afawcett commented 8 years ago

I've fixed this issue, update your copy of the ToolingAPIWSDL class with the latest one from this repo.