DescribeSObjectResult Class

Contains methods for describing sObjects.

Namespace

Schema

Usage

None of the methods take an argument.

DescribeSObjectResult Methods

The following are methods for DescribeSObjectResult. All are instance methods.

fields()

Returns a special data type that should not be used by itself. Instead, fields should always be followed by either a field member variable name or the getMap method.

Signature

public Schema.SObjectTypeFields fields()

Return Value

Type: Schema.SObjectTypeFields

The return value is a special data type that should not be used by itself.

Usage

Note

Note

When you describe sObjects and their fields from within an Apex class, custom fields of new field types are returned regardless of the API version that the class is saved in. If a field type, such as the geolocation field type, is available only in a recent API version, components of a geolocation field are returned even if the class is saved in an earlier API version.

For more information, see Understanding Apex Describe Information.

Example

Schema.DescribeFieldResult dfr = Schema.SObjectType.Account.fields.Name; 

fieldSets()

Returns a special data type that should not be used by itself. Instead, fieldSets should always be followed by either a field set name or the getMap method.

Signature

public Schema.SObjectTypeFields fieldSets()

Return Value

Type: Schema.SObjectTypeFields

The return value is a special data type that should not be used by itself.

Example

Schema.DescribeSObjectResult d = 
  Account.sObjectType.getDescribe();
Map<String, Schema.FieldSet> FsMap = 
  d.fieldSets.getMap();

getChildRelationships()

Returns a list of child relationships, which are the names of the sObjects that have a foreign key to the sObject being described.

Signature

public Schema.ChildRelationship getChildRelationships()

Return Value

Type: List<Schema.ChildRelationship>

Example

For example, the Account object includes Contacts and Opportunities as child relationships.

getKeyPrefix()

Returns the three-character prefix code for the object. Record IDs are prefixed with three-character codes that specify the type of the object (for example, accounts have a prefix of 001 and opportunities have a prefix of 006).

Signature

public String getKeyPrefix()

Return Value

Type: String

Usage

The DescribeSobjectResult object returns a value for objects that have a stable prefix. For object types that do not have a stable or predictable prefix, this field is blank. Client applications that rely on these codes can use this way of determining object type to ensure forward compatibility.

getLabel()

Returns the object's label, which may or may not match the object name.

Signature

public String getLabel()

Return Value

Type: String

Usage

The object's label might not always match the object name. For example, an organization in the medical industry might change the label for Account to Patient. This label is then used in the Salesforce user interface. See the Salesforce online help for more information.

getLabelPlural()

Returns the object's plural label, which may or may not match the object name.

Signature

public String getLabelPlural()

Return Value

Type: String

Usage

The object's plural label might not always match the object name. For example, an organization in the medical industry might change the plural label for Account to Patients. This label is then used in the Salesforce user interface. See the Salesforce online help for more information.

getLocalName()

Returns the name of the object, similar to the getName method. However, if the object is part of the current namespace, the namespace portion of the name is omitted.

Signature

public String getLocalName()

Return Value

Type: String

getName()

Returns the name of the object.

Signature

public String getName()

Return Value

Type: String

getRecordTypeInfos()

Returns a list of the record types supported by this object. The current user is not required to have access to a record type to see it in this list.

Signature

public List<Schema.RecordTypeInfo> getRecordTypeInfos()

Return Value

Type: List<Schema.RecordTypeInfo>

getRecordTypeInfosById()

Returns a map that matches record IDs to their associated record types. The current user is not required to have access to a record type to see it in this map.

Signature

public Schema.RecordTypeInfo getRecordTypeInfosById()

Return Value

Type: Map<ID, Schema.RecordTypeInfo>

getRecordTypeInfosByName()

Returns a map that matches record labels to their associated record type. The current user is not required to have access to a record type to see it in this map.

Signature

public Schema.RecordTypeInfo getRecordTypeInfosByName()

Return Value

Type: Map<String, Schema.RecordTypeInfo>

getSobjectType()

Returns the Schema.SObjectType object for the sObject. You can use this to create a similar sObject.

Signature

public Schema.SObjectType getSobjectType()

Return Value

Type: Schema.SObjectType

isAccessible()

Returns true if the current user can see this field, false otherwise.

Signature

public Boolean isAccessible()

Return Value

Type: Boolean

isCreateable()

Returns true if the object can be created by the current user, false otherwise.

Signature

public Boolean isCreateable()

Return Value

Type: Boolean

isCustom()

Returns true if the object is a custom object, false if it is a standard object.

Signature

public Boolean isCustom()

Return Value

Type: Boolean

isCustomSetting()

Returns true if the object is a custom setting, false otherwise.

Signature

public Boolean isCustomSetting()

Return Value

Type: Boolean

isDeletable()

Returns true if the object can be deleted by the current user, false otherwise.

Signature

public Boolean isDeletable()

Return Value

Type: Boolean

isDeprecatedAndHidden()

Reserved for future use.

Signature

public Boolean isDeprecatedAndHidden()

Return Value

Type: Boolean

isFeedEnabled()

Returns true if Chatter feeds are enabled for the object, false otherwise. This method is only available for Apex classes and triggers saved using SalesforceAPI version 19.0 and later.

Signature

public Boolean isFeedEnabled()

Return Value

Type: Boolean

isMergeable()

Returns true if the object can be merged with other objects of its type by the current user, false otherwise. true is returned for leads, contacts, and accounts.

Signature

public Boolean isMergeable()

Return Value

Type: Boolean

isQueryable()

Returns true if the object can be queried by the current user, false otherwise

Signature

public Boolean isQueryable()

Return Value

Type: Boolean

isSearchable()

Returns true if the object can be searched by the current user, false otherwise.

Signature

public Boolean isSearchable()

Return Value

Type: Boolean

isUndeletable()

Returns true if the object cannot be undeleted by the current user, false otherwise.

Signature

public Boolean isUndeletable()

Return Value

Type: Boolean

isUpdateable()

Returns true if the object can be updated by the current user, false otherwise.

Signature

public Boolean isUpdateable()

Return Value

Type: Boolean