DescribeSObjectResult Class

Contains methods for describing SObjects. None of the methods take an argument.

Schema

Instances of describe results on the same DescribeSObjectResult aren’t guaranteed to be equal because the state and behavior of a describe object is determined by various factors including the API version used. To compare describe results, call the getSObjectType() method on the SObject describe results and use the equality operator (==) to compare the SObjectType values.

The following are properties for DescribeSObjectResult.

Indicates whether the current user has access to the SObject.

public Boolean accessible {get; set;}

Type: Boolean

The type of associated object. For example, History or Share.

public String associateentitytype {get; set;}

Type: String

The parent object of an associated object.

public String associateparententity {get; set;}

Type: String

A list of child relationships, which is the name of the sObject that has a foreign key to the sObject being described.

public List<Schema.ChildRelationship> childrelationships {get; set;}

Type: List<Schema.ChildRelationship>

Indicates whether the SObject can be created by the current user.

public Boolean createable {get; set;}

Type: Boolean

Indicates whether the SObject is a custom object.

public Boolean custom {get; set;}

Type: Boolean

Indicates whether the SObject is a custom setting.

public Boolean customsetting {get; set;}

Type: Boolean

Indicates whether data translation is enabled for the SObject. This property is available in API version 49.0 and later.

public Boolean datatranslationenabled {get; set;}

Type: Boolean

Reserved for future use.

public String defaultimplementation {get; set;}

Type: String

Indicates whether the SObject can be deleted by the current user.

public Boolean deletable {get; set;}

Type: Boolean

Reserved for future use.

public Boolean deprecatedandhidden {get; set;}

Type: Boolean

Indicates whether Chatter feeds are enabled for the SObject.

public Boolean feedenabled {get; set;}

Type: Boolean

A list of fields associated with the SObject.

public Schema.SObjectTypeFields fields {get; set;}

Type: Schema.SObjectTypeFields

Follow fields with the getMap method.

This sample code shows how to use fields. To get a custom field, specify the custom field name.

Represents field sets, which is a grouping of the SObject fields.

public Schema.SObjectTypeFieldSets fieldsets {get; set;}

Type: Schema.SObjectTypeFieldSets

Follow fieldSets with a field set name or with the getMap method.

This sample code shows how to use fieldSet.

Reserved for future use.

public Boolean hassubtypes {get; set;}

Type: Boolean

Reserved for future use.

public String implementedby {get; set;}

Type: String

Reserved for future use.

public String implementsinterfaces {get; set;}

Type: String

Reserved for future use.

public Boolean isinterface {get; set;}

Type: Boolean

The three-character prefix code in the SObject ID.

public String keyprefix {get; set;}

Type: String

The SObject’s label, which may or may not match the object name. For example, an organization representing a medical vertical might rename Account to Patient. Tabs and fields can be renamed in the Salesforce user interface.

public String label {get; set;}

Type: String

The SObject’s plural label, which may or may not match the object name. For example, Accounts.

public String labelplural {get; set;}

Type: String

The name of the SObject. If the object is part of the current namespace, the namespace portion of the name is omitted.

public String localname {get; set;}

Type: String

Indicates whether the SObject can be merged with other objects of its type by the current user. This is set to true for leads, contacts, and accounts.

public Boolean mergeable {get; set;}

Type: Boolean

Indicates whether Most Recently Used (MRU) list functionality is enabled for the SObject.

public Boolean mruenabled {get; set;}

Type: Boolean

The name field of the SObject.

public String name {get; set;}

Type: String

Indicates whether the SObject can be queried by the current user.

public Boolean queryable {get; set;}

Type: Boolean

A list of the record types supported by the SObject.

public List<Schema.RecordTypeInfo> recordtypeinfos {get; set;}

Type: List<Schema.RecordTypeInfo>

A map that matches developer names to their associated record type.

public Map<String,Schema.RecordTypeInfo> recordtypeinfosbydevelopername {get; set;}

Type: Map<String, Schema.RecordTypeInfo>

A map that matches record IDs to their associated record types.

public Map<Id,Schema.RecordTypeInfo> recordtypeinfosbyid {get; set;}

Type: Map<ID, Schema.RecordTypeInfo>

A map that matches record labels to their associated record type.

public Map<String,Schema.RecordTypeInfo> recordtypeinfosbyname {get; set;}

Type: Map<String, Schema.RecordTypeInfo>

Indicates whether the SObject can be searched by the current user.

public Boolean searchable {get; set;}

Type: Boolean

The effective describe option used by the system for the SObject.

public Schema.SObjectDescribeOptions sobjectdescribeoption {get; set;}

Type: SObjectDescribeOptions Enum

The Schema.SObjectType object for the SObject.

public Schema.SObjectType sobjecttype {get; set;}

Type: Schema.SObjectType

Indicates whether the SObject can be undeleted by the current user.

public Boolean undeletable {get; set;}

Type: Boolean

Indicates whether the SObject can be updated by the current user.

public Boolean updateable {get; set;}

Type: Boolean

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

  • equals(obj)

    Compares the SObject to the specified object and returns true if both are equal. Otherwise, returns false.

  • getAssociateEntityType()

    Returns additional metadata for an associated object of a specified parent but only if it’s a specific associated object type. Used in combination with the getAssociateParentEntity() method to get the parent object. For example, invoking the method on AccountHistory returns the parent object as Account and the type of associated object as History.

  • getAssociateParentEntity()

    Returns additional metadata for an associated object but only if it’s associated to a specific parent object. Used in combination with the getAssociateEntityType() method to get the type of associated object. For example, invoking the method on AccountHistory returns the parent object as Account and the type of associated object as History.

  • getChildRelationships()

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

  • getDataTranslationEnabled()

    Returns true if data translation is enabled for the SObject. Otherwise, returns false.

  • getDefaultImplementation()

    Reserved for future use.

  • getFields()

    Returns the fields that make up the SObject being described.

  • getFieldSets()

    Returns field sets, which is a grouping of the SObject fields.

  • getHasSubtypes()

    Reserved for future use.

  • getImplementedBy()

    Reserved for future use.

  • getImplementsInterfaces()

    Reserved for future use.

  • getIsInterface()

    Reserved for future use.

  • 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).

  • getLabel()

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

  • getLabelPlural()

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

  • 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.

  • getName()

    Returns the name of the object.

  • 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.

  • getRecordTypeInfosByDeveloperName()

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

  • 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.

  • 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.

  • getSObjectDescribeOption()

    Returns the effective describe option used by the system for the SObject.

  • getSobjectType()

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

  • getHasSubtypes()

    Reserved for future use.

  • hashCode()

    Returns the hash code for the SObject.

  • isAccessible()

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

  • isCreateable()

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

  • isCustom()

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

  • isCustomSetting()

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

  • isDeletable()

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

  • isDeprecatedAndHidden()

    Reserved for future use.

  • 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.

  • 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.

  • isMruEnabled()

    Returns true if Most Recently Used (MRU) list functionality is enabled for the object, false otherwise.

  • isQueryable()

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

  • isSearchable()

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

  • isUndeletable()

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

  • isUpdateable()

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

  • toString()

    Returns a string that represents the SObject.

Compares the SObject to the specified object and returns true if both are equal. Otherwise, returns false.

public Boolean equals(Object obj)

obj

Type: Object

The object with which to compare.

Type: Boolean

Returns additional metadata for an associated object of a specified parent but only if it’s a specific associated object type. Used in combination with the getAssociateParentEntity() method to get the parent object. For example, invoking the method on AccountHistory returns the parent object as Account and the type of associated object as History.

public String associateentitytype {get; set;}

Type: String

See Also

Returns additional metadata for an associated object but only if it’s associated to a specific parent object. Used in combination with the getAssociateEntityType() method to get the type of associated object. For example, invoking the method on AccountHistory returns the parent object as Account and the type of associated object as History.

public String getAssociateParentEntity()

Type: String

See Also

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

public Schema.ChildRelationship getChildRelationships()

Type: List<Schema.ChildRelationship>

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

Returns true if data translation is enabled for the SObject. Otherwise, returns false.

public Boolean getDataTranslationEnabled()

Type: Boolean

Reserved for future use.

public String getDefaultImplementation()

Type: String

Returns the fields that make up the SObject being described.

public Schema.SObjectTypeFields getFields()

Type: Schema.SObjectTypeFields

The return value is a special data type. Call the getMap() method to get a map of Strings and SObjectFields.

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.

See Also

Returns field sets, which is a grouping of the SObject fields.

public Schema.SObjectTypeFieldSets getFieldSets()

Type: Schema.SObjectTypeFieldSets

The return value is a special data type. Call the getMap() method to get a map of Strings and SObjectFieldSets.

See Also

Reserved for future use.

To check if Person Accounts are enabled for the current org, use this code snippet: Schema.SObjectType.Account.fields.getMap().containsKey( 'isPersonAccount' );

public Boolean getHasSubtypes()

Type: Boolean

Reserved for future use.

public String getImplementedBy()

Type: String

Reserved for future use.

public String getImplementsInterfaces()

Type: String

Reserved for future use.

public Boolean getIsInterface()

Type: Boolean

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).

public String getKeyPrefix()

Type: String

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.

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

public String getLabel()

Type: String

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.

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

public String getLabelPlural()

Type: String

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.

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.

public String getLocalName()

Type: String

Returns the name of the object.

public String getName()

Type: String

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.

public List<Schema.RecordTypeInfo> getRecordTypeInfos()

Type: List<Schema.RecordTypeInfo>

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

public Map<String, Schema.RecordTypeInfo> getRecordTypeInfosByDeveloperName()

Type: Map<String, Schema.RecordTypeInfo>

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.

public Schema.RecordTypeInfo getRecordTypeInfosById()

Type: Map<ID, Schema.RecordTypeInfo>

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.

public Schema.RecordTypeInfo getRecordTypeInfosByName()

Type: Map<String, Schema.RecordTypeInfo>

Returns the effective describe option used by the system for the SObject.

public Schema.SObjectDescribeOptions getSObjectDescribeOption()

Type: Schema.SObjectDescribeOptions

Valid values are:

  • SObjectDescribeOptions.FULL: Indicates eager-load all elements of the describe, including child relationships, up-front at the time of method invocation.
  • SObjectDescribeOptions.DEFERRED: Indicates lazy-load child relationships. This means that all child relationships will not be loaded at the time of first invocation of the method.

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

public Schema.SObjectType getSobjectType()

Type: Schema.SObjectType

Reserved for future use.

To check if Person Accounts are enabled for the current org, use this code snippet: Schema.SObjectType.Account.fields.getMap().containsKey( 'isPersonAccount' );

public Boolean getHasSubtypes()

Type: Boolean

Returns the hash code for the SObject.

public Integer hashCode()

Type: Integer

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

public Boolean isAccessible()

Type: Boolean

In API version 54.0 and later, for custom settings and custom metadata type objects, DescribeSObjectResult.isAccessible() returns false if the user doesn’t have permissions to access the queried objects. In API version 53.0 and earlier, the method returns true even if the user doesn’t have the required permissions.

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

public Boolean isCreateable()

Type: Boolean

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

public Boolean isCustom()

Type: Boolean

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

public Boolean isCustomSetting()

Type: Boolean

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

public Boolean isDeletable()

Type: Boolean

Reserved for future use.

public Boolean isDeprecatedAndHidden()

Type: Boolean

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.

public Boolean isFeedEnabled()

Type: Boolean

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.

public Boolean isMergeable()

Type: Boolean

Returns true if Most Recently Used (MRU) list functionality is enabled for the object, false otherwise.

public Boolean isMruEnabled()

Type: Boolean

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

public Boolean isQueryable()

Type: Boolean

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

public Boolean isSearchable()

Type: Boolean

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

public Boolean isUndeletable()

Type: Boolean

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

public Boolean isUpdateable()

Type: Boolean

Returns a string that represents the SObject.

public String toString()

Type: String