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
D-PriceD-Price 

How to Query CustomObject via Metadata API?

Is there a way to query a CustomObject, like Account, to get all it's current metadata settings? It seems like all the examples expect you to create a new CustomObject, set the full name to "Account" and then run update. I've seen no clear examples of how to query the Account metadata analoguous to how you can query for Account records using the EnterpriseConnection query() method.

 

Is there a way to do this?

 

Thanks,

Derek

Nimble TedNimble Ted

Is the use case that you want to examine the metadata settings, and make a runtime decision based on the settings?

 

Or is the use case that you want a copy of the settings to look at yourself?

 

For the latter, the Force.com IDE and Metadata Toolkit can pull all the metadata and unmanaged source code for an org, acting like a Describe statement or SP_COLUMNS in TSQL.

 

D-PriceD-Price

Here's one use case. We have an external non-Salesforce licensing web application that will be enforcing what options are available for for a particular version of software we sell. The option information is stored as a dependent picklist tied to a version picklist. Both of these fields are custom fields on the Account object. As you select a particular version, different options are displayed for that version. We've been able to update the dependencies by basically brute forcing and completely re-creating the dependencies each time. It would be nice to query the metadata for these fields to see if they are current or need updating rather than just updating them every time. I know we can create an EnterpriseConnection and do the crazy bit shifting magic (getValidFor()) to determine this, but it would be nice to use a single connection to query the metadata directly.

D-PriceD-Price

You mentioned:

 

For the latter, the Force.com IDE and Metadata Toolkit can pull all the metadata and unmanaged source code for an org, acting like a Describe statement or SP_COLUMNS in TSQL.

 

We do not use the Force.com IDE, rather Intellij IDEA with the Enterprise and Metadata WSDL files. How do I pull this information with the metadata API?

 

Thanks,

Derek

PaqsPaqs

Hi D-Price,

 

I think what you are looking for is the SObject Describe methods, which allows you to do just that based on a given SObject.

 

See here: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dynamic_describe_objects_understanding.htm

 

With this you can for instance retrieve all the fields for a given SObject or its Fields picklists or values...

 

Hope this helps.