Newer Version Available

This content describes an older version of this product. View Latest

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

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

Example

Describe Apex class metadata in the Metadata namespace:

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

Describe Apex class metadata in the Tooling namespace:

1DescribeValueTypeResult = 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 All Data or Modify Metadata Through Metadata API Functions permission.

If a user requires access to metadata but not to data, you can enable the Modify Metadata Through Metadata API Functions permission to give the access the user needs without providing access to org data.

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.

1public void describeValueType() throws ConnectionException {
2    doDescribe("{http://soap.sforce.com/2006/04/metadata}CustomObject");
3    doDescribe("{http://soap.sforce.com/2006/04/metadata}CustomField");
4    doDescribe("{http://soap.sforce.com/2006/04/metadata}EmailTemplate");
5}
6
7public void doDescribe(String type) throws ConnectionException {
8    DescribeValueTypeResult result = metadataConnection.describeValueType(type);
9    StringBuffer sb = new StringBuffer();
10
11    sb.append("Describing " + type + " ...\n");
12
13    if (result.getApiCreatable() == true) {
14        sb.append("Is API creatable.\n");
15    } else {
16        sb.append("Is not API creatable.\n");
17    }
18
19    ValueTypeField parentField = result.getParentField();
20    if (parentField != null) {
21        sb.append("** Parent type fields **\n");
22        if (parentField.getIsForeignKey()) {
23            sb.append("This field is a foreign key.\n");
24            for (String fkDomain : parentField.getForeignKeyDomain()) { 
25                sb.append("Foreign key domain: " + fkDomain + "\n");
26            }
27        }              
28    }
29
30    sb.append("** Value type fields **\n");
31    for(ValueTypeField field : result.getValueTypeFields()) {
32        sb.append("***************************************************\n");
33        sb.append("Name: " + field.getName() + "\n");
34        sb.append("SoapType: " + field.getSoapType() + "\n");
35        if (field.getIsForeignKey()) {
36            sb.append("This field is a foreign key.\n");
37            for (String fkDomain : field.getForeignKeyDomain()) { 
38                sb.append("Foreign key domain: " + fkDomain + "\n");
39            }
40        }
41        sb.append("***************************************************\n");
42    }
43    System.out.println(sb.toString());
44}

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.

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

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

1Describing {http://soap.sforce.com/2006/04/metadata}CustomObject ...
2Is API creatable.
3** Value type fields **
4***************************************************
5Name: actionOverrides
6SoapType: ActionOverride
7***************************************************
8***************************************************
9Name: allowInChatterGroups
10SoapType: boolean
11***************************************************
12***************************************************
13Name: articleTypeChannelDisplay
14SoapType: ArticleTypeChannelDisplay
15***************************************************
16***************************************************
17Name: businessProcesses
18SoapType: BusinessProcess
19***************************************************
20***************************************************
21Name: compactLayoutAssignment
22SoapType: string
23***************************************************
24***************************************************
25Name: compactLayouts
26SoapType: CompactLayout
27***************************************************
28***************************************************
29Name: customHelp
30SoapType: string
31This field is a foreign key.
32Foreign key domain: ApexPage
33Foreign key domain: Scontrol
34***************************************************
35<The rest of the output for CustomObject has been omitted for brevity.>
36
37Describing {http://soap.sforce.com/2006/04/metadata}CustomField ...
38Is API creatable.
39** Parent type fields **
40This field is a foreign key.
41Foreign key domain: CustomObject
42** Value type fields **
43***************************************************
44Name: caseSensitive
45SoapType: boolean
46***************************************************
47***************************************************
48
49Name: defaultValue
50SoapType: string
51***************************************************
52
53<The rest of the output has been omitted for brevity.>