describeValueType()

Retrieves the metadata describing a given metadata type (value type).
describeValueType() accepts a namespace and a type name, and returns a DescribeValueTypeResult object. This call is available in API version 33.0 and later.

Syntax

DescribeValueTypeResult = connection.describeValueType("{namespace}type_name");

Example

Describe Apex class metadata in the Metadata namespace:

DescribeValueTypeResult = metadataConnection.describeValueType("{http://soap.sforce.com/2006/04/metadata}ApexClass");

Describe Apex class metadata in the Tooling namespace:

DescribeValueTypeResult = toolingConnection.describeValueType("{urn:metadata.tooling.soap.sforce.com}ApexClass");

Arguments

Name Type Description
type string The name of the metadata type for which you want metadata; for example, ApexClass. Include the namespace.

Permissions

Your client application must be logged in with the Modify Metadata Through Metadata API Functions or Modify All Data permission.

If a user requires access to metadata but not to data, enable the Modify Metadata Through Metadata API Functions permission. Otherwise, enable the Modify All Data permission.

Note

Sample Code—Java

The following example describes several metadata types by specifying the Metadata namespace. Each metadata type is described using the helper method, doDescribe(), which calls the describeValueType() Metadata API call. The sample retrieves information from the returned DescribeValueTypeResult: a property, the parent field (if any), and the fields. Next, the sample iterates through the fields and outputs information about each field.

public void describeValueType() throws ConnectionException {
    doDescribe("{http://soap.sforce.com/2006/04/metadata}CustomObject");
    doDescribe("{http://soap.sforce.com/2006/04/metadata}CustomField");
    doDescribe("{http://soap.sforce.com/2006/04/metadata}EmailTemplate");
}

public void doDescribe(String type) throws ConnectionException {
    DescribeValueTypeResult result = metadataConnection.describeValueType(type);
    StringBuffer sb = new StringBuffer();

    sb.append("Describing " + type + " ...\n");

    if (result.getApiCreatable() == true) {
        sb.append("Is API creatable.\n");
    } else {
        sb.append("Is not API creatable.\n");
    }

    ValueTypeField parentField = result.getParentField();
    if (parentField != null) {
        sb.append("** Parent type fields **\n");
        if (parentField.getIsForeignKey()) {
            sb.append("This field is a foreign key.\n");
            for (String fkDomain : parentField.getForeignKeyDomain()) { 
                sb.append("Foreign key domain: " + fkDomain + "\n");
            }
        }              
    }

    sb.append("** Value type fields **\n");
    for(ValueTypeField field : result.getValueTypeFields()) {
        sb.append("***************************************************\n");
        sb.append("Name: " + field.getName() + "\n");
        sb.append("SoapType: " + field.getSoapType() + "\n");
        if (field.getIsForeignKey()) {
            sb.append("This field is a foreign key.\n");
            for (String fkDomain : field.getForeignKeyDomain()) { 
                sb.append("Foreign key domain: " + fkDomain + "\n");
            }
        }
        sb.append("***************************************************\n");
    }
    System.out.println(sb.toString());
}

To run the previous example with the Tooling WSDL, replace the namespace with the Tooling namespace in the helper function call as follows. Also, use the Tooling connection instead of the Metadata connection to make the describeValueType() call.

doDescribe("{urn:metadata.tooling.soap.sforce.com}CustomObject");
    doDescribe("{urn:metadata.tooling.soap.sforce.com}CustomField");
    doDescribe("{urn:metadata.tooling.soap.sforce.com}EmailTemplate");

After you run the sample, the output looks similar to the following.

Describing {http://soap.sforce.com/2006/04/metadata}CustomObject ...
Is API creatable.
** Value type fields **
***************************************************
Name: actionOverrides
SoapType: ActionOverride
***************************************************
***************************************************
Name: allowInChatterGroups
SoapType: boolean
***************************************************
***************************************************
Name: articleTypeChannelDisplay
SoapType: ArticleTypeChannelDisplay
***************************************************
***************************************************
Name: businessProcesses
SoapType: BusinessProcess
***************************************************
***************************************************
Name: compactLayoutAssignment
SoapType: string
***************************************************
***************************************************
Name: compactLayouts
SoapType: CompactLayout
***************************************************
***************************************************
Name: customHelp
SoapType: string
This field is a foreign key.
Foreign key domain: ApexPage
Foreign key domain: Scontrol
***************************************************
<The rest of the output for CustomObject has been omitted for brevity.>

Describing {http://soap.sforce.com/2006/04/metadata}CustomField ...
Is API creatable.
** Parent type fields **
This field is a foreign key.
Foreign key domain: CustomObject
** Value type fields **
***************************************************
Name: caseSensitive
SoapType: boolean
***************************************************
***************************************************

Name: defaultValue
SoapType: string
***************************************************

<The rest of the output has been omitted for brevity.>