CustomField defines a field's data type, value rules, calculations, relationships, and selected governance and tracking settings. It supports custom fields on standard, custom, and external objects, plus customization of supported standard fields on standard objects. Fields belong to their object's definition even when addressed individually through Metadata API.
A field definition is separate from field-level security, which controls a user's ability to read or edit the field. It is also separate from the data stored in records. Creating a field does not establish effective user access, and retrieving its definition does not capture every aspect of its live state, such as an auto-number field's next-number counter.
Key Elements
| Element | What the Element Controls |
|---|---|
fullName, type
|
Component identity and field data type. Individually addressed fields use ObjectApiName.FieldApiName. Custom fields include type; supported standard-field definitions do not always include it. |
required, defaultValue, populateExistingRows
|
Whether creation requires a value, the default value, and whether existing rows are populated. A default alone does not establish that existing records have been populated. |
externalId, unique, caseSensitive
|
External-ID designation, uniqueness, and case sensitivity. An external ID is not automatically unique. For indirect lookups, case sensitivity affects matching to the target field. |
referenceTo, deleteConstraint
|
The related object and lookup-record deletion behavior. deleteConstraint accepts SetNull, the default, Restrict, or Cascade. |
relationshipOrder, reparentableMasterDetail, writeRequiresMasterRead
|
Primary or secondary master-detail status, whether children can move between parents, and the parent-record sharing access required to change children. |
lookupFilter |
Embedded lookup criteria. Its active and isOptional settings determine whether the filter is active and mandatory; criteria alone do not establish either. |
formula, formulaTreatBlanksAs
|
The calculation and treatment of missing inputs. Blank handling accepts BlankAsBlank or BlankAsZero. |
summaryForeignKey, summarizedField, summaryFilterItems, summaryOperation
|
The detail relationship, aggregated field, qualifying records, and roll-up operation. The aggregated field can be omitted only for a record count. Operation capitalization differs between the exposed schema and the reference table, as described below. |
valueSet |
Local picklist values through valueSetDefinition, a global value set through valueSetName, and dependencies through controllingField and valueSettings. |
encryptionScheme, maskChar, maskType
|
Shield Platform Encryption uses encryptionScheme: CaseInsensitiveDeterministicEncryption, CaseSensitiveDeterministicEncryption, None, or ProbabilisticEncryption. Classic Encryption uses the masking elements instead. |
businessStatus, securityClassification, complianceGroup
|
Declared usage, data sensitivity, and compliance categories. These describe the field; they do not enforce access or demonstrate compliance. |
metadataRelationshipControllingField, fieldManageability
|
Dependent metadata-relationship choices and post-release field changes on custom metadata types. Manageability values are Locked, DeveloperControlled, and SubscriberControlled. |
trackFeedHistory, trackHistory, trackTrending
|
Feed tracking, field history tracking, and historical trending. These are separate mechanisms with different object-level prerequisites. |
startingNumber, stripMarkup
|
The deployment starting number for an auto-number field, and whether markup is removed when converting a rich text area to a long text area. Metadata API cannot retrieve startingNumber. |
mktDataLakeFieldAttributes, mktDataModelFieldAttributes
|
Specialized Data 360 lake-field and model-field settings, including primary-key ordering, event-date selection, latest-record identification, and invalid-merge handling. |
Behavior and Constraints
Access, encryption, and governance
Profile and PermissionSet configurations participate in field access. A CustomField definition alone does not establish a user's effective read or edit permissions.
Shield Platform Encryption and Classic Encryption use different settings. For Classic Encryption text fields, maskChar accepts asterisk or X, and maskType accepts all, creditCard, lastFour, nino, sin, or ssn. Do not interpret these masking settings as a Shield encryption scheme.
The following governance elements appear only when an administrator has set them:
-
businessStatus: declared usage ofActive,DeprecateCandidate, orHidden. -
securityClassification: sensitivity ofPublic,Internal,Confidential,Restricted, orMissionCritical. -
complianceGroup: semicolon-separated categories drawn fromCCPA,COPPA,GDPR,HIPAA,PCI, andPII. -
description: the field's documented purpose. -
inlineHelpText: field-level guidance shown to users.
Declared usage is not observed usage. In particular, Hidden does not mean field access has been disabled. Sensitivity and compliance classifications do not enforce permissions or prove regulatory compliance. Description and help text explain intent but are not themselves sensitivity classifications. Missing governance metadata does not establish that a field is unused or contains harmless data.
businessOwnerGroup and businessOwnerUser identify business owners who understand the data's importance and can help determine its minimum security classification. The group association does not itself grant access.
Relationships and record integrity
referenceTo identifies the related object. For lookup relationships, deleteConstraint controls what happens when the referenced record is deleted: SetNull clears the lookup, Restrict prevents deletion while the relationship exists, and Cascade selects cascading deletion. These settings concern records, not deletion of the field definition.
For master-detail relationships, reparentableMasterDetail controls whether child records can move to a different parent; its default is false. A junction object connects two parents through two master-detail relationships. Its relationshipOrder must identify one relationship as primary, 0, and the other as secondary, 1. This distinction affects deletion behavior, ownership, and inherited presentation. Non-junction master-detail relationships use 0.
writeRequiresMasterRead=true permits users with Read access to the parent record to create, edit, or delete child records. The default, false, requires Read/Write access. Junction objects enforce the most restrictive access from their two parents. A conflicting published example leaves one mixed-access combination unclear; see Documentation Inconsistencies.
required specifies whether creation requires a value. externalId and unique are separate settings. Retrieval returns externalId only for AutoNumber, Email, Number, and Text custom fields.
Lookup filters
lookupFilter is embedded in the field definition, not a separate field deployment identity. Each filter supports up to 10 filterItems, with booleanFilter expressing advanced combinations. Within an item, field and valueField can reference other fields; value supplies a comparison value.
Evaluate active together with isOptional. An active optional filter is different from an active mandatory filter. errorMessage explains a filter failure, while infoMessage can explain why choices are excluded. Lookup filters are not supported on article type objects.
Picklists and dependent values
A picklist either defines local values under valueSet.valueSetDefinition or references a GlobalValueSet through valueSet.valueSetName. A global-value-set-backed custom picklist is restricted. Add or remove its available values by editing the global value set, not each consuming field independently.
For dependent picklists, valueSet.controllingField identifies the controlling field. Entries in valueSettings map controllingFieldValue entries to dependent valueName entries. These mappings are separate from the source of available values: fields can share a global value set while each has its own dependency configuration.
Formulas, summaries, and data transitions
formula can contain references to other fields and custom labels. Those dependencies can be embedded in an expression rather than exposed as a simple reference element.
A roll-up summary combines summaryForeignKey, which identifies the child's master-detail field, with summaryOperation, the aggregation to perform. summarizedField identifies the detail field being aggregated and can be omitted only when counting records. summaryFilterItems limits which detail records qualify.
defaultValue does not establish that existing records have been populated; populateExistingRows is separate. When converting a rich text area to a long text area, stripMarkup=true removes markup and false preserves it.
Tracking prerequisites
-
trackFeedHistory=truerequiresenableFeeds=trueon the associatedCustomObject. -
trackHistory=truerequiresenableHistory=trueon the associated object. Field history tracking is unavailable for external objects. -
trackTrending=trueon at least one field enables the object for historical trending.
Enabling one tracking mechanism does not establish that either of the others is enabled.
External object fields
External objects use CustomObject metadata, but they have a different field compatibility surface. They do not support formula, geolocation, master-detail, roll-up summary, encrypted text, or rich text area fields. Auto-number, currency, picklist, and multi-select picklist fields are available only with the Salesforce Connect cross-org adapter.
externalDeveloperName maps the field to a column in the external data source. isNameField applies only to Text fields. Only one field per external object can be its name field, and the mapped external column must contain name values.
For an indirect lookup, referenceTargetField identifies the custom field on the parent object used to match external values. That parent field must have both externalId=true and unique=true. caseSensitive affects matching. The relationship therefore depends on both the target field's identity and its external-ID and uniqueness settings.
Custom metadata relationships and managed packages
On custom metadata types, a metadata relationship to FieldDefinition or EntityParticle requires metadataRelationshipControllingField. The controlling EntityDefinition relationship specifies the object and limits the fields or entity particles available in the dependent relationship.
fieldManageability applies only to fields on custom metadata types and controls changes after managed-package release:
-
Locked: the field cannot be updated. -
DeveloperControlled: the field can change through a package upgrade. -
SubscriberControlled: users with appropriate permissions can change the field, but a package upgrade cannot.
Manageability is coupled for metadata relationships. A subscriber-controlled entity-definition relationship requires a subscriber-controlled field-definition relationship. An upgradeable entity-definition relationship permits either an upgradeable or subscriber-controlled field-definition relationship.
Data 360 fields
Data 360 data lake objects (DLOs) and data model objects (DMOs) support Checkbox, Date, DateTime, Email, Number, Percent, Phone, Text, and Url fields. Lookup is supported for DMOs only.
mktDataLakeFieldAttributes and mktDataModelFieldAttributes carry specialized settings, not general CRM-field behavior. Within these structures, primaryIndexOrder identifies primary-key membership and orders attributes in a compound key, starting at 1.
For behavioral-model-area lake fields, isEventDate identifies the event date used to partition data. isRecordModified identifies the field used to determine the latest record version. For model fields used in merging, invalidMergeActionType selects Drop, Keep, or Override when an invalid merge occurs.
Deployment and Retrieval
Identity, containers, and manifest selection
Creating, updating, or deleting an individually addressed field requires a non-null fullName in ObjectApiName.FieldApiName form, such as Account.Customer_Code__c, Account.Phone, or External_Order__x.Status__c. Inside CustomObject.fields, fullName is field-local, such as Customer_Code__c.
In package.xml, select individual fields as CustomField members using their object-qualified names. CustomField does not support the * wildcard in the manifest. Metadata API retrieval places the requested field definitions within object definitions, such as objects/Account.object.
Retrieving an object returns its associated metadata except unsupported, noncustomizable standard fields. Standard-field support is limited to fields that allow customization, such as help text, history tracking, or feed tracking. System fields, standard auto-number fields, and some standard picklists are excluded. You cannot update a standard picklist field's label through label. A supported standard-field definition can omit type.
Retrieving a field also includes corresponding field information in any Profile and PermissionSet components retrieved in the same package. Field selection therefore changes the access metadata returned by a combined retrieval. See the CustomField API reference for the field and object retrieval model.
Picklist deployment is not append-only
Picklist values omitted from a value-defining component are deactivated when that component is deployed. This applies to values of both standard and custom fields. A partial value list can therefore deactivate values that were not intended to change.
Retrieving global picklist values returns active and inactive values. Retrieving a non-global, unrestricted picklist returns only active values, so that local retrieval is not a complete inventory of inactive values. A value's isActive controls whether users can select it; it is distinct from whether the value appears in a particular retrieval.
Local value entries use the CustomValue structure. They are retrieved or deployed with their containing CustomObject or GlobalValueSet, rather than as independent file-based components.
State that a retrieved field does not fully capture
Metadata API cannot retrieve startingNumber for an AutoNumber field. A retrieved definition therefore does not capture the live next-number counter. The documented deployment default for a custom auto-number field is 1 when no starting number is supplied. That default does not establish that updating an existing field definition resets its sequence.
Data 360 DLO and DMO retrieval returns properties according to the field's data type, not every CustomField property. Deployment fails if a supplied property is unsupported for that data type, even if it is valid for another kind of field.
Dependencies and removal scope
Metadata API supports deletion of custom field definitions using their component identity. Lookup deleteConstraint is not a field-removal setting. A reported Tooling API deletion limitation and a destructive-deployment approach are described under Reported Issues.
Deployment scope depends on actual references and destination state. A field can depend on other fields through a formula, lookup filter, dependent picklist, metadata relationship, or roll-up summary. Incoming references can occur in access rules, validation and duplicate rules, approval processes, layouts, record-type picklist configuration, translations, automation, code, email templates, reports, analytics, forecasting, and data mappings.
Some references are embedded in formulas or component file contents, represented as filedata, rather than standalone field-reference elements. The types capable of referencing fields are not automatically dependencies of every field deployment.
Relationships
CustomObject contains field definitions and supplies object-level tracking prerequisites. Fields can reference related objects, other fields, labels, global value sets, and business-owner groups. The incoming list below describes possible connections, not evidence that a particular field is used by all of these types.
References
-
CustomField:controllingField,field,formula,metadataRelationshipControllingField,referenceTargetField,summarizedField,summaryForeignKey,valueField. -
CustomLabel:formula. -
CustomObject:referenceTo. -
GlobalValueSet:valueSetName. -
Group:businessOwnerGroup.
Referenced By
AccountingFieldMapping, AccountPlanObjMeasCalcDef, AccountRelationshipShareRule, ActionableListDefinition, ActionPlanTemplate, AdvAccountForecastSet, AIUsecaseDefinition, AnalyticSnapshot, AnimationRule, ApexClass, ApexComponent, ApexPage, ApexTrigger, ApprovalProcess, AssignmentRules, AssignmentRule, Audience, AutoResponseRules, AutoResponseRule, BatchCalcJobDefinition, BatchProcessJobDefinition, Bot, BotVersion, BotBlock, BotTemplate, BriefcaseDefinition, CareProviderSearchConfig, CareSystemFieldMapping, ChannelLayout, CleanDataService, ConversationMessageDefinition, CustomApplication, CustomMetadata, CustomObject, CompactLayout, CustomField, FieldSet, ListView, RecordType, ValidationRule, CustomObjectTranslation, Dashboard, DataObjectSearchIndexConf, DataSrcDataModelFieldMap, DataStreamDefinition, DecisionTable, DecisionTableDatasetLink, DiscoveryAIModel, DiscoveryGoal, DuplicateRule, EmailTemplate, EntitlementProcess, EscalationRules, EscalationRule, ExpressionSetObjectAlias, ExtlClntAppSamlConfigurablePolicies, FieldSrcTrgtRelationship, FlexiPage, Flow, FlowTest, ForecastingFilterCondition, ForecastingSourceDefinition, ForecastingTypeSource, IdentityVerificationProcDef, LightningWebComponent, LightningMessageChannel, MatchingRules, MatchingRule, MLDataDefinition, MLPredictionDefinition, ModerationRule, MutingPermissionSet, NamedCredential, ObjectSourceTargetMap, Layout, PathAssistant, PermissionSet, PlatformEventChannelMember, PlatformEventSubscriberConfig, PostTemplate, Profile, QuickAction, RecommendationStrategy, RelatedRecordAssocCriteria, Report, ReportType, SalesWorkQueueSettings, SearchCustomization, SearchOrgWideObjectConfig, ServiceAISetupField, ServiceChannel, SharingRules, SharingCriteriaRule, SharingGuestRule, SharingOwnerRule, SharingTerritoryRule, SharingSet, SvcCatalogFulfillmentFlow, TerritoryModel, UiFormatSpecificationSet, UIObjectRelationConfig, Workflow, WorkflowAlert, WorkflowFieldUpdate, WorkflowOutboundMessage, WorkflowRule, WorkflowTask, WorkSkillRouting.
Documentation Inconsistencies
-
Junction-object sharing example: the stated behavior of
writeRequiresMasterRead=truerequires only Read access to a parent. However, the published example denies child changes when both relationship flags aretrueand the user has Read access to one parent and Read/Write access to the other. That example does not reliably resolve this combination. Effective access requires examining both parent relationships and actual sharing. -
Global value-set element name: the
CustomFieldprose namesvalueNameas the alternative tovalueSetDefinition. The exposed global-reference element isvalueSetName.valueNamebelongs undervalueSettingsand identifies a dependent picklist value. -
Roll-up operation capitalization: the exposed element enumeration lists
count,min,max, andsum, while the Salesforce reference table listsCount,Min,Max, andSum. This discrepancy matters when constructing serialized metadata; the two presentations do not establish that capitalization is interchangeable.
Reported Issues
-
A missing-field error can originate in destination state even without a source reference. In a 2021
PermissionSetdeployment report, the named field had been deleted but not erased in the target. Deployment still failed after erasure and later succeeded after waiting and saving the permission set's object settings without changes. The reporter could not distinguish delayed cleanup from the effect of saving. This is a diagnostic lead, not a guaranteed repair procedure. Permission set and deleted-field report. -
A missing standard field can indicate a destination feature configuration difference. A 2024 report of a
Profiledeployment failing onCase.SourceIdwas resolved by enabling Email-to-Case in the destination. That result applies to the reported configuration, not every missing-field error. Case.SourceId deployment report. -
Successful validation did not guarantee that a translation deployment included its field. In a 2024 Jenkins report, validation succeeded but deployment of
Contact-frreported a missingContact.New_Field__c. Switching the pipeline from Delta to Full deployment resolved the failure. This was pipeline-specific, not a requirement that field translations always use full deployments. Translation deployment scope report. -
A partial Tooling API update could fail on required data-type properties. In a 2018 report, a successful
PATCHfor a Number field includedlabel,type,precision, andscalealongside the changed description. Removing properties such asprecisionproduced a field-integrity error. The answer did not establish every required-property combination. Number-field update report. -
Tooling API deletion was reported as unsupported, rather than a permissions-only failure. In a 2021 discussion, a
DELETErequest returnedINSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY. The answer identified the lack of a Tooling API delete operation forCustomFieldand described a Metadata API deployment usingdestructiveChanges.xml, with the object-qualified field name as aCustomFieldmember. Field deletion API discussion.
Common Questions
How do I retrieve one CustomField in package.xml?
Use a CustomField member such as Account.Customer_Code__c. The name must include the object and field API names. CustomField does not support * in the manifest. Metadata API returns the requested field within its object definition.
Does deploying a CustomField grant field-level security?
No. The field definition and field access are separate. Profile and PermissionSet configurations participate in read and edit access. Retrieving those components together with a field also affects which field-access information is returned.
Why did deploying a picklist deactivate other values?
Values omitted from a value-defining component are deactivated on deployment for both standard and custom fields. A partial list is not an append-only update. For a field backed by a global value set, change the available values in that global value set.
Why is startingNumber missing from my retrieved auto-number field?
Metadata API cannot retrieve startingNumber. The retrieved definition does not capture the live next-number counter. The documented custom-field deployment default is 1 when no starting number is supplied, but that does not establish that updating an existing field resets its sequence.
Why does deployment say no CustomField was found when my source has no reference?
Reported causes include deleted-field state in the destination, destination feature configuration, and differences between pipeline validation and deployment scope. The reported permission-set cleanup, Email-to-Case, and Delta-to-Full outcomes are conditional diagnostic leads, not universal fixes.