You need to sign in to do that
Don't have an account?
SOQL metadata through web service API
I am using Apache Axis to access the Web Services API. However, I believe my question is not specific to the Java API, and is applicable to all Web Service clients.
I am using the partner.wsdl Version 16.0.
Is there a way for a Web Service query() method call to return the metadata of the SOQL query? Specifically, the fields that were requested in joined object. My issue is that if the joined object has no rows, then all I get back in the SOAP message is an empty object.
For example:
I have two Account objects: with name/billingcity "Acct A"/"Boston" and "Acct B"/"New York".
And "Acct A" has two Contact objects, but "Acct B" has no Contact objects.
If I query for:
select a.Name, a.BillingCity, (Select Email, LastName From Contacts) from Account a where a.Name = 'Acct A'
I will get back the Name and BillingCity of the Account, along with the Email and LastName of both the Contacts. From this data, I can interpret that the SOQL query asked for these four fields.
However, If I query for:
select a.Name, a.BillingCity, (Select Email, LastName From Contacts) from Account a where a.Name = 'Acct B'
I will get back the Name and BillingCity of the Account, along with an empty Contact XML node. From this data, I have no way of knowing the SOQL query asked for Contact Email and LastName.
I need this metadata to present back to my client the list of fields that they requested, even if the object/fields are null.
Is there a way for me to get this metadata?
thanks!
All Answers
Thanks for the suggestion.
Since my code does not create the SOQL query, I would need to parse the SOQL query string that is given to me. This is an option. However, as Salesforce develops the SOQL syntax further, I would need to update the parsing in my application to keep up with the specification.
For example, if Salesforce added some of the functions you see in SQL (union/min/max/decode) or more complicated subselects, the query parsing would become more complicated.
Since Salesforce is the owner of the SOQL specification, and already parses the query request, I would guess that it is possible to return that information to the requestor. This would be similar to what you get from a JDBC call.
Does this make sense?
I have the same problem. I have posted suggestion to Salesforce to implement enhancement to their API here.