Schema.DescribeFieldResult F = Account.AccountNumber.getDescribe();
None of the methods take an argument.
| Name | Data Type | Description |
|---|---|---|
| getByteLength | Integer | For variable-length fields (including binary fields), returns the maximum size of the field, in bytes |
| getCalculatedFormula | String | Returns the formula specified for this field |
| getController | Schema.sObjectField | Returns the token of the controlling field |
| getDefaultValue | Object | Returns the default value for this field |
| getDefaultValueFormula | String | Returns the default value specified for this field if a formula is not used |
| getDigits | Integer | Returns the maximum number of digits specified for the field. This method is only valid with Integer fields |
| getInlineHelpText | String | Returns the content of the field-level help. For more information, see Defining Field-Level Help. |
| getLabel | String | Returns the text label that is displayed next to the field in the Salesforce user interface. This label can be localized. |
| getLength | Integer | For string fields, returns the maximum size of the field in Unicode characters (not bytes) |
| getLocalName | String | Returns the name of the field, similar to the getName method. However, if the field is part of the current namespace, the namespace portion of the name is omitted. |
| getName | String | Returns the field name used in Apex |
| getPicklistValues | List <Schema.PicklistEntry> | Returns a list of PicklistEntry objects. A runtime error is returned if the field is not a picklist. |
| getPrecision | Integer | For fields of type Double, returns the 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) |
| getReferenceTo | List <Schema.sObjectType> | Returns a list of Schema.sObjectType objects for the parent objects of this field. If the isNamePointing method returns true, there is more than one entry in the list, otherwise there is only one. |
| getRelationshipName | String | Returns the name of the relationship. For more information about relationships and relationship names, see Understanding Relationship Names in the Web Services API Developer's Guide. |
| getRelationshipOrder | Integer | Returns 1 if the field is a child, 0 otherwise. For more information about relationships and relationship names, see Understanding Relationship Names in the Web Services API Developer's Guide. |
| getScale | Integer | For fields of type Double, returns the number of digits to the right of the decimal point. Any extra digits to the right of the decimal point are truncated. This method returns a fault response if the number has too many digits to the left of the decimal point. |
| getSOAPType | Schema.SOAPType | Returns one of the SoapType enum values, depending on the type of field. For more information, see Schema.SOAPType Enum Values. |
| getSObjectField | Schema.sObjectField | Returns the token for this field |
| getType | Schema.DisplayType | Returns one of the DisplayType enum values, depending on the type of field. For more information, see Schema.DisplayType Enum Values. |
| isAccessible | Boolean | Returns true if the current user can see this field, false otherwise |
| isAutoNumber | Boolean | Returns true if the
field is an Auto Number field, false otherwise. Analogous to a SQL IDENTITY type, Auto Number fields are read-only, non-createable text fields with a maximum length of 30 characters. Auto Number fields are used to provide a unique ID that is independent of the internal object ID (such as a purchase order number or invoice number). Auto Number fields are configured entirely in the Salesforce user interface. |
| isCalculated | Boolean | Returns true if the field is a custom formula field, false otherwise. Note that custom formula fields are always read-only. |
| isCascadeDelete | Boolean | Returns true if the child object is deleted when the parent object is deleted, false otherwise. |
| isCaseSensitive | Boolean | Returns true if the field is case sensitive, false otherwise |
| isCreateable | Boolean | Returns true if the field can be created by the current user, false otherwise |
| isCustom | Boolean | Returns true if the field is a custom field, false if it is a standard object |
| isDefaultedOnCreate | Boolean | Returns true if the field receives a default value when created, false otherwise. If true, 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). |
| isDependentPicklist | Boolean | Returns true if the picklist is a dependent picklist, false otherwise |
| isDeprecatedAndHidden | Boolean | Reserved for future use. |
| isExternalID | Boolean | Returns true if the field is used as an external ID, false otherwise |
| isFilterable | Boolean | Returns true if the field can be used as part of the filter criteria of a WHERE statement, false otherwise |
| isGroupable | Boolean | Returns true if the field can be included in the GROUP BY clause of a SOQL query, false otherwise. This method is only available for Apex classes and triggers saved using API version 18.0 and higher. |
| isHtmlFormatted | Boolean | Returns true if the field has been formatted for HTML and should be encoded for display in HTML, false otherwise. One example of a field that returns true for this method is a hyperlink custom formula field. Another example is a custom formula field that has an IMAGE text function. |
| isIdLookup | Boolean | Returns true if the field can be used to specify a record in an upsert method, false otherwise |
| isNameField | Boolean | Returns true if the
field is a name field, false otherwise. This method is used to identify the name field for standard objects (such as AccountName for an Account object) and custom objects. Objects can only have one name field, except where the FirstName and LastName fields are
used instead (such as on the Contact object). If a compound name is present, for example, the Name field on a person account, isNameField is set to true for that record. |
| isNamePointing | Boolean | Returns true if the field can have multiple types of objects as parents. For example, a task can have both the Contact/Lead ID (WhoId) field and the Opportunity/Account ID (WhatId) field return true for this method. because either of those objects can be the parent of a particular task record. This method returns false otherwise. |
| isNillable | Boolean | Returns true if the field is nillable, false otherwise. A nillable field can have empty content. A non-nillable field must have a value for the object to be created or saved. |
| isPermissionable | Boolean | Returns true if field permissions can be specified for the field, false otherwise. |
| isRestrictedDelete | Boolean | Returns true if the parent object can't be deleted because it is referenced by a child object, false otherwise. |
| isRestrictedPicklist | Boolean | Returns true if the field is a restricted picklist, false otherwise |
| isSortable | Boolean | Returns true if a query can sort on the field, false otherwise |
| isUnique | Boolean | Returns true if the value for the field must be unique, false otherwise |
| isUpdateable | Boolean | Returns true if the field can be edited by the current user, false otherwise |
| isWriteRequiresMasterRead | Boolean | Returns true if writing to the detail object requires read sharing instead of read/write sharing of the parent. |
A Schema.DisplayType enum value is returned by the field describe result's getType method. For more information, see Field Types in the Web Services API Developer's Guide. For more information about the methods shared by all enums, see Enum Methods.
| Type Field Value | What the Field Object Contains |
|---|---|
| anytype | Any value of the following types: String, Picklist, Boolean, Integer, Double, Percent, ID, Date, DateTime, URL, or Email. |
| base64 | Base64-encoded arbitrary binary data (of type base64Binary) |
| Boolean | Boolean (true or false) values |
| Combobox | Comboboxes, which provide a set of enumerated values and allow the user to specify a value not in the list |
| Currency | Currency values |
| DataCategoryGroupReference | Reference to a data category group or a category unique name. |
| Date | Date values |
| DateTime | DateTime values |
| Double | Double values |
| Email addresses | |
| EncryptedString | Encrypted string |
| ID | Primary key field for an object |
| Integer | Integer values |
| MultiPicklist | Multi-select picklists, which provide a set of enumerated values from which multiple values can be selected |
| Percent | Percent values |
| Phone | Phone numbers. Values can include alphabetic characters. Client applications are responsible for phone number formatting. |
| Picklist | Single-select picklists, which provide a set of enumerated values from which only one value can be selected |
| Reference | Cross-references to a different object, analogous to a foreign key field |
| String | String values |
| TextArea | String values that are displayed as multiline text fields |
| Time | Time values |
| URL | URL values that are displayed as hyperlinks |
Picklist fields contain a list of one or more items from which a user chooses a single item. They display as drop-down lists in the Salesforce user interface. One of the items can be configured as the default item.
A Schema.PicklistEntry object is returned from the field describe result using the getPicklistValues method. For example:
Schema.DescribeFieldResult F = Account.Industry.getDescribe(); List<Schema.PicklistEntry> P = F.getPicklistValues();
You can only use 100getPicklistValue method calls per Apex request. For more information about governor limits, see Understanding Execution Governors and Limits.
The following table describes the methods available as part of the PicklistEntry object. None of the methods take an argument.
| Name | Data Type | Description |
|---|---|---|
| getLabel | String | Returns the display name of this item in the picklist |
| getValue | String | Returns the value of this item in the picklist |
| isActive | Boolean | Returns true if this item must be displayed in the drop-down list for the picklist field in the user interface, false otherwise |
| isDefaultValue | Boolean | Returns true if this item is the default value for the picklist, false otherwise. Only one item in a picklist can be designated as the default. |
A Schema.sObjectField object is returned from the field describe result using the getControler and getSObjectField methods. For example:
Schema.DescribeFieldResult F = Account.Industry.getDescribe(); Schema.sObjectField T = F.getSObjectField();
The following table describes the method available as part of the sObjectField object. This method does not take an argument.
| Name | Data Type | Description |
|---|---|---|
| getDescribe | Schema.DescribeFieldResult | Returns the describe field result for this field. |
A Schema.sObjectType object is returned from the field describe result using the getReferenceTo method, or from the sObject describe result using the getSObjectType method. For example:
Schema.DescribeFieldResult F = Account.Industry.getDescribe(); List<Schema.sObjectType> P = F.getReferenceTo();
The following table describes the methods available as part of the sObjectType object.
| Name | Argument | Data Type | Description |
|---|---|---|---|
| getDescribe | Schema.DescribeSObjectResult | Returns the describe sObject result for this field. | |
| newSObject | sObject | Constructs a new sObject of this type. For an example, see Creating sObjects Dynamically. |
|
| newSObject | Id Id | sObject | Constructs a new sObject of this type, with the specified ID. For the argument, pass the ID of an existing record in the database. After you create a new sObject, the sObject returned has all fields set to null. You can set any updateable field to desired values and then update the record in the database. Only the fields you set new values for are updated and all other fields which are not system fields are preserved. |
A schema.SOAPType enum value is returned by the field describe result getSoapType method.
For more information, see SOAPTypes in the Web Services API Developer's Guide. For more information about the methods shared by all enums, see Enum Methods.
| Type Field Value | What the Field Object Contains |
|---|---|
| anytype | Any value of the following types: String, Boolean, Integer, Double, ID, Date or DateTime. |
| base64binary | Base64-encoded arbitrary binary data (of type base64Binary) |
| Boolean | Boolean (true or false) values |
| Date | Date values |
| DateTime | DateTime values |
| Double | Double values |
| ID | Primary key field for an object |
| Integer | Integer values |
| String | String values |
| Time | Time values |