The describeSObjects() call returns an array of DescribeSObjectResult objects. Each object has the following properties:
| Name | Type | Description |
|---|---|---|
| activateable | boolean | Reserved for future use. |
| childRelationships | ChildRelationship[] | An array of child relationships, which is the name of the sObject that has a foreign key to the sObject being described. |
| createable | boolean | Indicates whether the object can be created via the create() call (true) or not (false). |
| custom | boolean | Indicates whether the object is a custom object (true) or not (false). |
| deletable | boolean | Indicates whether the object can be deleted via the delete() call (true) or not (false). |
| fields | Field[] | Array of fields associated with the object. The mechanism for retrieving information from this list varies among development tools. |
| keyPrefix | string | Three-character prefix code in the object ID. Object IDs are
prefixed with three-character codes that specify the type of the object.
For example, Account objects have a prefix of 001 and Opportunity objects have a prefix of 006. Use the value of this field to determine the object type of a parent in those cases where the child may have more than one object type as parent (polymorphic). For example, you may need to obtain the keyPrefix value for the parent of a Task or Event. |
| label | string | Label text for a tab or field renamed in the user interface, if applicable, or the object name, if not. For example, an organization representing a medical vertical might rename Account to Patient. Tabs and fields can be renamed in the Salesforce user interface. See the Salesforce online help for more information. |
| labelPlural | string | Label text for an object that represents the plural version of an object name, for example, “Accounts.” |
| layoutable | boolean | Indicates whether the object supports the describeLayout() call (true) or not (false). |
| mergeable | boolean | Indicates whether the object can be merged with other objects of its type (true) or not (false). true for leads, contacts, and accounts. |
| name | string | Name of the object. This is the same string that was passed in as the sObjectType parameter. |
| queryable | boolean | Indicates whether the object can be queried via the query() call (true) or not (false). |
| recordTypeInfos | RecordTypeInfo[] | An array of the record types supported by this object. The user need not have access to all the returned record types to see them here. |
| relationshipOrder | int | This field is valid for all
master-detail relationships, but the value is only non-zero for junction
objects. A junction object has two master-detail relationships, and
is analogous to an association table in a many-to-many relationship.
Junction objects must define one parent object as primary (0), the
other as secondary (1). The definition of primary or secondary affects
delete behavior and inheritance of look and feel, and record ownership
for junction objects. For more information, see the Salesforce online
help.
0 or 1 are the only valid values, and 0 is always the value for objects that are not junction objects. |
| replicateable | boolean | Indicates whether the object can be replicated via the getUpdated() and getDeleted() calls (true) or not (false). |
| retrieveable | boolean | Indicates whether the object can be retrieved via the retrieve() call (true) or not (false). |
| searchable | boolean | Indicates whether the object can be searched via the search() call (true) or not (false). |
| undeletable | boolean | Indicates whether an object can be undeleted using the undelete() call (true) or not (false). |
| updateable | boolean | Indicates whether the object can be updated via the update() call (true) or not (false). |
| urlDetail | string | URL to the read-only detail page for this object. Compare with urlEdit, which is read-write. Client applications can use this URL to redirect to, or access, the Salesforce user interface for standard and custom objects. To provide flexibility and allow for future enhancements, returned urlDetail values are dynamic. To ensure that client applications are forward compatible, it is recommended that they use this capability where possible. Note that, for objects for which a stable URL is not available, this field is returned empty. |
| urlEdit | string | URL to the edit page for this object. For example, the urlEdit field for the Account object returns https://na1.salesforce.com/{ID}/e. Substituting the {ID} field for the current object ID will return the edit page for that specific account in the Salesforce user interface. Compare with urlDetail, which is read-only. Client applications can use this URL to redirect to, or access, the Salesforce user interface for standard and custom objects. To provide flexibility and allow for future enhancements, returned urlDetail values are dynamic. To ensure that client applications are forward compatible, it is recommended that they use this capability where possible. Note that, for objects for which a stable URL is not available, this field is returned empty. |
| urlNew | string | URL to the new/create page for this object. Client applications can use this URL to redirect to, or access, the Salesforce user interface for standard and custom objects. To provide flexibility and allow for future enhancements, returned urlNew values are dynamic. To ensure that client applications are forward compatible, it is recommended that they use this capability where possible. Note that, for objects for which a stable URL is not available, this field is returned empty. |
| writeRequiresMasterRead | boolean | Sets the minimum sharing
access level required on the master record to create, edit, or delete
child records. This field applies only to master-detail or junction
object custom field types.
For junction objects, the most restrictive access from the two parents is enforced. For example, if you set to true on both master-detail fields, but users have "Read" access to one master record and "Read/Write" access to the other master record, users won't be able to create, edit, or delete child records. |
The name of the sObject that has a foreign key to the sObject being described.
| Name | Type | Description |
|---|---|---|
| cascadeDelete | boolean | Indicates whether the child object is deleted when the parent object is deleted (true) or not (false). |
| childSObject | string | The name of the object on which there is a foreign key back to the parent sObject. |
| field | string | The name of the field that has a foreign key back to the parent sObject. |
| relationshipName | string | The name of the relationship, usually the plural of the value in childSObject. |
In the DescribeSObjectResult, the fields property contains an array of Field objects. Each field represents a field in an API object. The array contains only the fields that the user can view, as defined by the user's field-level security settings.
| Name | Type | Description |
|---|---|---|
| autonumber | boolean | Indicates whether this field is an autonumber field (true) or not (false). Analogous to a SQL IDENTITY type, autonumber fields are read only, non-createable text fields with a maximum length of 30 characters. Autonumber fields are read-only fields used to provide a unique ID that is independent of the internal object ID (such as a purchase order number or invoice number). Autonumber fields are configured entirely in the Salesforce user interface. The API provides access to this attribute so that client applications can determine whether a given field is an autonumber field. |
| byteLength | int | For variable-length fields (including binary fields), the maximum size of the field, in bytes. |
| calculated | boolean | Indicates whether the field is a custom formula field (true) or not (false). Note that custom formula fields are always read-only. |
| caseSensitive | boolean | Indicates whether the field is case sensitive (true) or not (false). |
| controllerName | string | The name of the field that controls the values of this picklist. It only applies if type is picklist or multipicklist and dependentPicklist is true. See About Dependent Picklists. The mapping of controlling field to dependent field is stored in the validFor attribute of each PicklistEntry for this picklist. See validFor. |
| createable | boolean | Indicates whether the field can be created (true) or not (false). If true, then this field value can be set in a create() call. |
| custom | boolean | Indicates whether the field is a custom field (true) or not (false). |
| defaultedOnCreate | boolean | Indicates whether this field is defaulted when created (true) or not (false). If true, then Salesforce implicitly assigns a value for this field when the object is created, even if a value for this field is not passed in on the create() call. For example, in the Opportunity object, the Probability field has this attribute because its value is derived from the Stage field. Similarly, the Owner has this attribute on most objects because its value is derived from the current user (if the Owner field is not specified). |
| defaultValueFormula | string | The default value specified for this field if the formula is not used. If no value has been specified, this field is not returned. |
| dependentPicklist | boolean | Indicates whether a picklist is a dependent picklist (true) where available values depend on the chosen values from a controlling field, or not (false). See About Dependent Picklists. |
| digits | int | For fields of type integer. Maximum number of digits. The API returns an error if an integer value exceeds the number of digits. |
| filterable | boolean | Indicates whether the field is filterable (true) or not (false). If true, then this field can be specified in the WHERE clause of a query string in a query() call. |
| formula | string | The formula specified for this field. If no formula is specified for this field, it is not returned. |
| htmlFormatted | boolean | Indicates whether a field such as a hyperlink custom formula field has been formatted for HTML and should be encoded for display in HTML (true) or not (false). Also indicates whether a field is a custom formula field that has an IMAGE text function. |
| idLookup | boolean | Indicates whether the field can be used to specify a record in an upsert() call (true) or not (false). |
| inlineHelpText | string | The text that displays in the field-level help hover text for this field. |
| label | string | Text label that is displayed next to the field in the Salesforce user interface. This label can be localized. |
| length | int | For string fields, the maximum size of the field in Unicode characters (not bytes). |
| name | string | Field name used in API calls, such as create(), delete(), and query(). |
| nameField | boolean |
Indicates whether this field is a name field (true) or not (false). Used to identify the name field for standard objects (such as AccountName for an Account object) and custom objects. Limited to one per object, except where FirstName and LastName fields are used (such as in the Contact object). If a compound name is present, for example the Name field on a person account, nameField is set to true for that record. If no compound name is present, FirstName and LastName have this field set to true. |
| namePointing | boolean | Indicates whether the field's value is the Name of the parent of this object (true) or not (false). Used for objects whose parents may be more than one type of object, for example a task may have an account or a contact as a parent. |
| nillable | boolean | Indicates whether the field is nillable (true) or not (false). A nillable field can have empty content. A non-nillable field must have a value in order for the object to be created or saved. |
| picklistValues | PicklistEntry[] | Provides the list of valid values for the picklist. Specified only if restrictedPicklist is true. |
| precision | int | For fields of type double. Maximum number of digits that can be stored, including all numbers to the left and to the right of the decimal point (but excluding the decimal point character). |
| relationshipName | string | The name of the relationship. |
| referenceTo | string[] | For fields that refer to other objects, this array indicates the object types of the referenced objects. |
| restrictedPicklist | boolean | Indicates whether the field is a restricted picklist (true) or not (false). |
| scale | int | For fields of type double. Number of digits to the right of the decimal point. The API silently truncates any extra digits to the right of the decimal point, but it returns a fault response if the number has too many digits to the left of the decimal point. |
| soapType | SOAPType | See SOAPType for a list of allowable values. |
| sortable | boolean | Indicates whether a query can sort on this field (true) or not (false). |
| type | FieldType | See FieldType for a list of allowable values. |
| unique | boolean | Indicates whether the value must be unique true) or not false). |
| updateable | boolean | Indicates whether the field is updateable (true) or not (false). If true, then this field value can be set in an update() call. |
In the Field object associated with the DescribeSObjectResult, the type field can contain one of the following strings. For more information about field types, see Field Types.
| type Field Value | What the Field Object Contains |
|---|---|
| string | String values. |
| boolean | Boolean (true / false) values. |
| int | Integer values. |
| double | Double values. |
| cdate | Date values. |
| dateTime | Date and time values. |
| base64 | Base64-encoded arbitrary binary data (of type base64Binary). Used for Attachment, Document, and Scontrol objects. |
| ID | Primary key field for the object. For information on IDs, see ID Field Type |
| reference | Cross-references to a different object. Analogous to a foreign key field in SQL. |
| currency | Currency values. |
| textarea | String that is displayed as a multiline text field. |
| percent | Percentage values. |
| phone | Phone numbers. Values can include alphabetic characters. Client applications are responsible for phone number formatting. |
| url | URL values. Client applications should commonly display these as hyperlinks. |
| Email addresses. | |
| combobox | Comboboxes, which provide a set of enumerated values and allow the user to specify a value not in the list. |
| picklist | Single-select picklists, which provide a set of enumerated values from which only one value can be selected. |
| multipicklist | multi-select picklists, which provide a set of enumerated values from which multiple values can be selected. |
| anyType | Values can be any of these types: string, picklist, boolean, int, double, percent, ID, date, dateTime, url, or email. |
The DescribeSObjectResult returns the fields property, which contains an array of fields whose value provides information about the object being described. One of those fields, soapType, contains one of the following string values. All of the values preceded by xsd: are XML schema primitive data types. For more information about the XML schema primitive data types, see the World Wide Web Consortium’s publication XML Schema Part 2: Data Types at: http://www.w3.org/TR/xmlschema-2/.
| Value | Description |
|---|---|
| tns:ID | Unique ID associated with an sObject. For information on IDs, see ID Field Type. |
| xsd:anyType | Can be ID, Boolean, double, integer, string, date, or dateTime. |
| xsd:base64Binary | Base 64-encoded binary data. |
| xsd:boolean | Boolean (true / false) values. |
| xsd:date | Date values. |
| xsd:dateTime | Date/time values. |
| xsd:double | Double values. |
| xsd:int | Integer values. |
| xsd:string | Character strings. |
In the Field object associated with the DescribeSObjectResult, the picklistValues field contains an array of PicklistEntry properties. Each PicklistEntry can contain any one of the following string values. For more information, see Picklist Field Type.
| Name | Type | Description |
|---|---|---|
| active | boolean | Indicates whether this item must be displayed (true) or not (false) in the drop-down list for the picklist field in the user interface. |
| validFor | byte[] | A set of bits where each bit indicates a controlling value for which this PicklistEntry is valid. See About Dependent Picklists. |
| defaultValue | boolean | Indicates whether this item is the default item (true) in the picklist or not (false). Only one item in a picklist can be designated as the default. |
| label | string | Display name of this item in the picklist. |
| value | string | Value of this item in the picklist. |
A dependent picklist works in conjunction with a controlling field to filter its values. The value chosen in the controlling field affects the values available in the dependent picklist.
A dependent picklist can be any custom picklist or multi-select picklist field that displays available values based on the value selected in its corresponding controlling field. A controlling field can be any standard or custom picklist (with at least one and less than 200 values) or checkbox field whose values control the available values in one or more corresponding dependent fields.
In the following example, the controlling picklist Beverage has two values, which relate to the values of the dependent picklist Beverage Variety:
| Beverage | Beverage Variety |
|---|---|
| Coffee | Decaffeinated |
| Regular | |
| Tea | Chamomile |
| Earl Grey | |
| English Breakfast |
For each PicklistEntry that represents a value in a dependent picklist, the validFor attribute contains a set of bits. Each bit indicates a controlling field value for which the PicklistEntry is valid. Read the bits from left to right.
For more information on dependent picklists, see the “About Dependent Fields” topic in the Salesforce online help.
// helper class to decode a "validFor" bitset class Bitset {
byte[] data;
public Bitset(byte[] data) {
this.data = data == null?new byte[0]:data;
}
public boolean testBit(int n) {
return (data[n>>3] & (0x80 >> n % 8)) != 0;
}
public int size() {
return data.length * 8;
}
}
...
DescribeSObjectResult describeSObjectResult = getClient().describeSObject("Case");
Field[] fields = describeSObjectResult.getFields();
// create a map of all fields for later lookup
Map fieldMap = new HashMap();
for(int i=0;i<fields.length;i++) {
fieldMap.put(fields[i].getName(),fields[i]);
}
for(int i=0;i<fields.length;i++) {
// check whether this is a dependent picklist
if(Boolean.TRUE.equals(fields[i].getDependentPicklist())) {
// get the controller by name
Field controller = (Field)fieldMap.get(fields[i].getControllerName());
System.out.println("Field '"+fields[i].getLabel()+"' depends on '"+controller.getLabel()+"'");
PicklistEntry[] picklistValues = fields[i].getPicklistValues();
for(int j = 0;j<picklistValues.length;j++) {
// for each PicklistEntry: list all controlling values for which it is valid
System.out.println("Item: '"+picklistValues[j].getLabel()+"' is valid for:");
Bitset validFor = new Bitset(picklistValues[j].getValidFor());
if("picklist".equals(controller.getType().getValue())) {
// if the controller is a picklist, list all
// controlling values for which this entry is valid
for(int k = 0;k<validFor.size();k++) {
if(validFor.testBit(k)) {
// if bit k is set, this entry is valid for the
// for the controlling entry at index k
System.out.println(" "+controller.getPicklistValues()[k].getLabel());
}
}
} else if("boolean".equals(controller.getType().getValue())) {
// the controller is a checkbox
// if bit 1 is set this entry is valid if the controller is checked
if(validFor.testBit(1)) {
System.out.println(" checked");
}
// if bit 0 is set this entry is valid if the controller is not checked
if(validFor.testBit(0)) {
System.out.println(" unchecked");
}
}
}
}
}
Base class for the old RecordTypeMapping object. This object contains all of the existing fields of RecordtypeMapping except layoutId and picklistForRecordType.