DescribeFieldResult Class
Namespace
Usage
Instances of field describe results on the same DescribeFieldResult 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 getSObjectField() method on the field describe results and use the equality operator (==) to compare the SObjectField values.
Example
Schema.DescribeFieldResult dfr = Account.Description.getDescribe();
DescribeFieldResult Methods
The following are methods for DescribeFieldResult. All are instance methods.
getByteLength()
Signature
public Integer getByteLength()
Return Value
Type: Integer
getCalculatedFormula()
Signature
public String getCalculatedFormula()
Return Value
Type: String
getController()
Signature
public Schema.sObjectField getController()
Return Value
Type: Schema.SObjectField
getDefaultValue()
Signature
public Object getDefaultValue()
Return Value
Type: Object
getDefaultValueFormula()
Signature
public String getDefaultValueFormula()
Return Value
Type: String
getDigits()
Signature
public Integer getDigits()
Return Value
Type: Integer
getInlineHelpText()
Signature
public String getInlineHelpText()
Return Value
Type: String
Usage
For more information, see “Define Field-Level Help” in the Salesforce online help.
getLabel()
Signature
public String getLabel()
Return Value
Type: String
Usage
getLength()
Signature
public Integer getLength()
Return Value
Type: Integer
getLocalName()
Signature
public String getLocalName()
Return Value
Type: String
getPicklistValues()
Signature
public List<Schema.PicklistEntry> getPicklistValues()
Return Value
Type: List<Schema.PicklistEntry>
getPrecision()
Signature
public Integer getPrecision()
Return Value
Type: Integer
getReferenceTargetField()
Signature
public String getReferenceTargetField()
Return Value
Type: String
Usage
For information about indirect lookup relationships, see “Indirect Lookup Relationship Fields on External Objects” in the Salesforce Help.
getReferenceTo()
Signature
public List <Schema.sObjectType> getReferenceTo()
Return Value
Type: List<Schema.sObjectType>
Versioned Behavior Changes
In API version 51.0 and later, the getReferenceTo() method returns referenced objects that aren’t accessible to the context user. If the context user has access to an object’s field that references another object, irrespective of the context user’s access to the cross-referenced object, the method returns references. In API version 50.0 and earlier, if the context user doesn’t have access to the cross-referenced object, the method returns an empty list.
getRelationshipName()
Signature
public String getRelationshipName()
Return Value
Type: String
Usage
For more information about relationships and relationship names, see Understanding Relationship Names in the SOQL and SOSL Reference.
getRelationshipOrder()
Signature
public Integer getRelationshipOrder()
Return Value
Type: Integer
Usage
For more information about primary and secondary relationships, see Considerations for Object Relationships. For more information about relationships and relationship names, see Understanding Relationship Names in the SOQL and SOSL Reference.
getScale()
Signature
public Integer getScale()
Return Value
Type: Integer
getSOAPType()
Signature
public Schema.SOAPType getSOAPType()
Return Value
Type: Schema.SOAPType
getSObjectField()
Signature
public Schema.sObjectField getSObjectField()
Return Value
Type: Schema.SObjectField
getSObjectType()
Signature
public Schema.SObjectType getSObjectType()
Return Value
Type: Schema.SObjectType
Example
Schema.DescribeFieldResult f = Account.Industry.getDescribe();
Schema.sObjectType sourceType = f.getSObjectType();
Assert.areEqual(Account.sObjectType, sourceType);
getType()
Signature
public Schema.DisplayType getType()
Return Value
Type: Schema.DisplayType
isAccessible()
Signature
public Boolean isAccessible()
Return Value
Type: Boolean
isAiPredictionField() (Beta)
Signature
public Boolean isAiPredictionField()
Return Value
Type: Boolean
Usage
isAutoNumber()
Signature
public Boolean isAutoNumber()
Return Value
Type: Boolean
Usage
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()
Signature
public Boolean isCalculated()
Return Value
Type: Boolean
isCascadeDelete()
Signature
public Boolean isCascadeDelete()
Return Value
Type: Boolean
isCaseSensitive()
Signature
public Boolean isCaseSensitive()
Return Value
Type: Boolean
isCreateable()
Signature
public Boolean isCreateable()
Return Value
Type: Boolean
isCustom()
Signature
public Boolean isCustom()
Return Value
Type: Boolean
isDefaultedOnCreate()
Signature
public Boolean isDefaultedOnCreate()
Return Value
Type: Boolean
Usage
If this method returns 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()
Signature
public Boolean isDependentPicklist()
Return Value
Type: Boolean
isDeprecatedAndHidden()
Signature
public Boolean isDeprecatedAndHidden()
Return Value
Type: Boolean
isEncrypted()
Signature
public Boolean isEncrypted()
Return Value
Type: Boolean
isExternalID()
Signature
public Boolean isExternalID()
Return Value
Type: Boolean
isFilterable()
Signature
public Boolean isFilterable()
Return Value
Type: Boolean
isFormulaTreatNullNumberAsZero()
Signature
public Boolean isFormulaTreatNullNumberAsZero()
Return Value
Type: Boolean
isGroupable()
Signature
public Boolean isGroupable()
Return Value
Type: Boolean
isHtmlFormatted()
Signature
public Boolean isHtmlFormatted()
Return Value
Type: Boolean
isIdLookup()
Signature
public Boolean isIdLookup()
Return Value
Type: Boolean
isNameField()
Signature
public Boolean isNameField()
Return Value
Type: Boolean
Usage
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()
Signature
public Boolean isNamePointing()
Return Value
Type: Boolean
isNillable()
Signature
public Boolean isNillable()
Return Value
Type: Boolean
isPermissionable()
Signature
public Boolean isPermissionable()
Return Value
Type: Boolean
isRestrictedDelete()
Signature
public Boolean isRestrictedDelete()
Return Value
Type: Boolean
isRestrictedPicklist()
Signature
public Boolean isRestrictedPicklist()
Return Value
Type: Boolean
isSearchPrefilterable()
Signature
public Boolean isSearchPrefilterable()
Return Value
Type: Boolean
Usage
Prefiltering means to filter by a specific field value before executing the full search query. Prefiltering is supported only in WHERE clauses with the equals (=) operator.
isSortable()
Signature
public Boolean isSortable()
Return Value
Type: Boolean
isUnique()
Signature
public Boolean isUnique()
Return Value
Type: Boolean
isUpdateable()
Signature
public Boolean isUpdateable()
Return Value
Type: Boolean
isWriteRequiresMasterRead()
Signature
public Boolean isWriteRequiresMasterRead()
Return Value
Type: Boolean