Field Schema Details Available Using $ObjectType

The $ObjectType global variable provides access to a variety of schema information about the objects in your organization. Use it to reference names, labels, and data types of fields on an object, for example.

Where possible, we changed noninclusive terms to align with our company value of Equality. We maintained certain terms to avoid any effect on customer implementations.

Important

The information available using $ObjectType parallels but is a subset of the details available using the Apex describe result, the DescribeFieldResult object. This table describes the attributes available from the $ObjectType global variable.

NameData TypeDescription
byteLengthIntegerFor variable-length fields (including binary fields), the maximum size of the field, in bytes.
calculatedFormulaStringThe formula specified for this field.
controllerSchema.sObjectField (as a string)The controlling field, if this is a dependent field.
defaultValueFormulaStringThe default value specified for this field if a formula isn’t used.
digitsIntegerThe maximum number of digits specified for the field, or zero for non-numeric fields.
inlineHelpTextStringThe content of the field-level help.
labelStringThe text label that’s displayed next to the field in the Salesforce user interface. This label can be localized.
lengthIntegerFor string fields, the maximum size of the field in Unicode characters (not bytes).
localNameStringThe name of the field.
nameStringThe field name used in Apex.
picklistValuesList <Schema.PicklistEntry>A list of the field’s picklist items, or an empty list if the field is not a picklist.
precisionIntegerFor fields of type Double, 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).
referenceToList <Schema.sObjectType>A list of the parent objects of this field. If the namePointing attribute is true, there’s more than one entry in the list, otherwise there’s only one.
relationshipNameStringThe name of the relationship. For more information about relationships and relationship names, see Understanding Relationship Names in the SOQL and SOSL Reference.
relationshipOrderIntegerThis attribute is 1 if the field is a child, 0 otherwise. For more information about relationships and relationship names, see Understanding Relationship Names in the SOQL and SOSL Reference.
scaleIntegerFor fields of type Double, the number of digits to the right of the decimal point. Any extra digits to the right of the decimal point are truncated.
soapTypeSchema.SOAPType (as a string)One of the SoapType enum values, depending on the type of field. For more information, see SOAPType Enum in the Apex Developer Guide.
sObjectFieldSchema.sObjectField (as a string)A reference to this field.
typeSchema.DisplayType (as a string)One of the DisplayType enum values, depending on the type of field. For more information, see DisplayType Enum in the Apex Developer Guide.
accessibleBooleantrue if the current user can see this field, false otherwise.
autoNumberBooleantrue if the field is an Auto Number field, false otherwise.
calculatedBooleantrue if the field is a custom formula field, false otherwise.
cascadeDeleteBooleantrue if the child object is deleted when the parent object is deleted, false otherwise.
caseSensitiveBooleantrue if the field is case sensitive, false otherwise.
createableBooleantrue if the field can be created by the current user, false otherwise.
customBooleantrue if the field is a custom field, false if it’s a standard object.
defaultedOnCreateBooleantrue if the field receives a default value when created, false otherwise.
dependentPicklistBooleantrue if the picklist is a dependent picklist, false otherwise.
externalIdBooleantrue if the field is used as an external ID, false otherwise.
filterableBooleantrue if the field can be used as part of the filter criteria of a WHERE statement, false otherwise.
groupableBooleantrue if the field can be included in the GROUP BY clause of a SOQL query, false otherwise.
htmlFormattedBooleantrue if the field has been formatted for HTML and should be encoded for display in HTML, false otherwise. One example of a field that is true for this attribute is a hyperlink custom formula field. Another example is a custom formula field that has an IMAGE text function.
idLookupBooleantrue if the field can be used to specify a record in an upsert method, false otherwise.
nameFieldBooleantrue 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).
namePointingBooleantrue 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 be true for this attribute because either of those objects can be the parent of a particular task record. This attribute is false otherwise.
nillableBooleantrue if the field is nillable, false otherwise.
permissionableBooleantrue if field permissions can be specified for the field, false otherwise.
restrictedDeleteBooleantrue if the parent object can’t be deleted because it’s referenced by a child object, false otherwise.
restrictedPicklistBooleantrue if the field is a restricted picklist, false otherwise.
sortableBooleantrue if a query can sort on the field, false otherwise.
uniqueBooleantrue if the value for the field must be unique, false otherwise.
updateableBooleantrue if: The field can be edited by the current user, or. Child records in a master-detail relationship field on a custom object can be reparented to different parent records.false otherwise.
writeRequiresMasterReadBooleantrue if writing to the detail object requires read sharing instead of read/write sharing of the parent.

See Also