Loading...
Loading...
Use this skill when users need to create, generate, or validate Salesforce Custom Field metadata. Trigger when users mention custom fields, field types, Roll-up Summary fields, Master-Detail relationships, Lookup relationships, formula fields, picklists, dependent (controlling) picklists, referencing a value set from a field, or scoping/limiting picklist values for a specific record type. Also use when users encounter field deployment errors, especially around Roll-up Summary format, Master-Detail constraints, formula issues, or a record type that won't deploy without a business process. Use this skill for custom field metadata work, field generation, and field troubleshooting. DO NOT TRIGGER for creating or customizing the value set itself — defining a new GlobalValueSet, or modifying a StandardValueSet catalog like Industry or Lead Source — use platform-value-set-generate instead; this skill covers the field that references a value set, not the value set definition.
npx skill4agent add forcedotcom/afv-library platform-custom-field-generate| Attribute | Requirement | Notes |
|---|---|---|
| Required | Field name only: derive from |
| Required | The UI name (Title Case) |
| Always include | Explain the business reason why this field exists. |
| Always include | Actionable end-user guidance that adds value beyond the label (e.g., "Enter the value in USD including tax", not "The amount"). |
<description><inlineHelpText>force-app/main/default/objects/<Object>/fields/<FieldName>__c.field-meta.xml<Object>AccountOpportunityInventory_Item__c<externalId>true</externalId>precisionscaleprecision ≤ 18scale ≤ precisionprecision - scale<length>255</length>length| Type | | Required Attributes |
|---|---|---|
| Auto Number | | |
| Checkbox | | Default |
| Date | | No precision/length required |
| Date/Time | | No precision/length required |
| Built-in format validation | |
| Lookup Relationship | | |
| Master-Detail Relationship | | |
| Number | | |
| Currency | | Default precision: 18, scale: 2 |
| Percent | | Default precision: 5, scale: 2 |
| Phone | | Standardizes phone number formatting |
| Picklist | | |
| Text | | |
| Text Area | | |
| Text (Long) | | |
| Text (Rich) | | |
| Time | | Stores time only (no date) |
| URL | | Validates for protocol and format |
| Type | | Required Attributes |
|---|---|---|
| Formula | Result type (e.g., | |
| Roll-Up Summary | | See Section 5 for complete requirements |
| Multi-Select Picklist | | |
| Type | | Required Attributes |
|---|---|---|
| Geolocation | | |
restricted<restricted>true</restricted><valueSet><valueSet>
<restricted>true</restricted>
<valueSetDefinition>
<sorted>false</sorted>
<value><fullName>Option_A</fullName><default>false</default><label>Option A</label></value>
</valueSetDefinition>
</valueSet><valueSetDefinition>references/advanced-picklists.md<valueSet><valueSetName><valueSetDefinition>IndustryPriority_Levels__gvs__c__gvs<restricted>true</restricted>platform-value-set-generate<fullName><label>Closed WonClosed_Won___c<controllingField><valueSettings><controllingFieldValue><valueName><picklist><picklistValues><controllingFieldValues><restricted>true</restricted><value><color>#<isActive>false<description><picklistValues><fullName><businessProcess>Required field is missing: businessProcessbusinessProcesses/<Name>.businessProcess-meta.xml<businessProcess><Name></businessProcess><RecordType><active><picklistValues><fullName>*__c| Forbidden Attribute | Why | What Happens |
|---|---|---|
| Master-Detail is ALWAYS required by design | Deployment error |
| Master-Detail ALWAYS cascades deletes | Deployment error |
| Only supported on Lookup fields | Deployment error |
| Attribute | Master-Detail | Lookup |
|---|---|---|
| ❌ FORBIDDEN | ✅ Optional |
| ❌ FORBIDDEN (always CASCADE) | ✅ Required ( |
| ❌ FORBIDDEN | ✅ Optional |
| ✅ Required (0 or 1) | ❌ Not applicable |
| ✅ Optional | ❌ Not applicable |
| ✅ Optional | ❌ Not applicable |
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>Account__c</fullName>
<type>MasterDetail</type>
<referenceTo>Account</referenceTo>
<relationshipName>Contacts</relationshipName>
<relationshipOrder>0</relationshipOrder>
<required>true</required> <!-- WRONG: remove -->
<deleteConstraint>Cascade</deleteConstraint> <!-- WRONG: remove -->
<lookupFilter>...</lookupFilter> <!-- WRONG: remove entire block -->
</CustomField>Master-Detail Relationship Fields Cannot be Optional or RequiredCan not specify 'deleteConstraint' for a CustomField of type MasterDetailLookup filters are only supported on Lookup Relationship Fields<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>Account__c</fullName>
<label>Account</label>
<description>Links this record to its parent Account</description>
<type>MasterDetail</type>
<referenceTo>Account</referenceTo>
<relationshipLabel>Child Records</relationshipLabel>
<relationshipName>ChildRecords</relationshipName>
<relationshipOrder>0</relationshipOrder>
<reparentableMasterDetail>false</reparentableMasterDetail>
<writeRequiresMasterRead>false</writeRequiresMasterRead>
<!-- NO required, deleteConstraint, or lookupFilter -->
</CustomField><CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>Related_Account__c</fullName>
<label>Related Account</label>
<description>Optional link to a related Account</description>
<type>Lookup</type>
<referenceTo>Account</referenceTo>
<relationshipLabel>Related Records</relationshipLabel>
<relationshipName>RelatedRecords</relationshipName>
<required>false</required>
<deleteConstraint>SetNull</deleteConstraint>
<lookupFilter>
<active>true</active>
<filterItems>
<field>Account.Type</field>
<operation>equals</operation>
<value>Customer</value>
</filterItems>
<isOptional>false</isOptional>
</lookupFilter>
</CustomField>01Travel_Bookings| Element | Requirement | Format |
|---|---|---|
| Required | Always |
| Required | |
| Required | |
| Conditional | Required for |
| Forbidden Attribute | Why |
|---|---|
| Summary inherits from summarized field |
| Summary inherits from summarized field |
| Not applicable to Summary fields |
| Not applicable to Summary fields |
summaryForeignKeysummarizedFieldChildObjectAPIName__c.FieldAPIName__csummaryForeignKeyChildObject__c.MasterDetailFieldOnChild__csummarizedFieldChildObject__c.FieldToSummarize__c<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>Total_Amount__c</fullName>
<label>Total Amount</label>
<type>Summary</type>
<precision>18</precision> <!-- WRONG: Remove - inherited from source -->
<scale>2</scale> <!-- WRONG: Remove - inherited from source -->
<summaryOperation>sum</summaryOperation>
<summaryForeignKey>Order__c</summaryForeignKey> <!-- WRONG: Missing field name -->
<summarizedField>Amount__c</summarizedField> <!-- WRONG: Missing object name -->
</CustomField>Can not specify 'precision' for a CustomField of type SummaryMust specify the name in the CustomObject.CustomField format (e.g. Account.MyNewCustomField)<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>Total_Amount__c</fullName>
<label>Total Amount</label>
<description>Sum of all line item amounts</description>
<inlineHelpText>Automatically calculated from child line items</inlineHelpText>
<type>Summary</type>
<summaryOperation>sum</summaryOperation>
<summarizedField>Order_Line_Item__c.Amount__c</summarizedField>
<summaryForeignKey>Order_Line_Item__c.Order__c</summaryForeignKey>
<!-- NO precision, scale, required, or length -->
</CustomField><summarizedField><summaryForeignKey><summaryOperation>min</summaryOperation>max<summarizedField>| Operation | summarizedField Required? | Use Case |
|---|---|---|
| NO | Count number of child records |
| YES | Add up numeric values |
| YES | Find smallest value |
| YES | Find largest value |
<formula><type>CheckboxCurrencyDateDateTimeNumberPercentText<formula><![CDATA[ ... ]]>&<>]]><![CDATA[Text_Field__c & "]]]]><![CDATA[>"]]>returnType<type>NumberCurrencyPercent<formulaTreatBlanksAs>BlankAsZero</formulaTreatBlanksAs>TextDateDateTime<formulaTreatBlanksAs>BlankAsBlank</formulaTreatBlanksAs><CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>Calculated_Value__c</fullName>
<type>Formula</type> <!-- WRONG: Formula is not a valid type -->
<returnType>Number</returnType> <!-- WRONG: returnType does not exist in Metadata API -->
<formula>Field1__c + Field2__c</formula> <!-- WRONG: Missing CDATA wrapper -->
</CustomField><CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>Calculated_Value__c</fullName>
<label>Calculated Value</label>
<description>Sum of Field1 and Field2</description>
<type>Number</type> <!-- Result type, not "Formula" -->
<precision>18</precision>
<scale>2</scale>
<formula><![CDATA[Field1__c + Field2__c]]></formula>
<formulaTreatBlanksAs>BlankAsZero</formulaTreatBlanksAs>
</CustomField>ISPICKVAL()==platform-validation-rule-generate| Error Message | Cause | Fix |
|---|---|---|
| XML comments placed before the root | Remove XML comments ( |
| Referenced field does not exist or has not been deployed yet | Verify the referenced field exists and is deployed before this field |
| Field fullName already exists on the object | Use a unique business-driven name |
| More than 2 Master-Detail or 15 Lookup fields on the object | Use Lookup for 3rd+ Master-Detail; review Lookup count |
| Reserved keyword error | Using | Rename to |
| | Keep exactly one (see Section 3.4) |
| Two | Make every picklist value |
| Value | Start with a letter; no hyphens, no leading digit. Spaces ARE allowed — do NOT underscore them (see §3.4 value-name fidelity) |
| Deprecated ≤37.0 dependent-picklist syntax ( | Use the modern |
<fullName>__c<description><inlineHelpText><label><!-- ... --><CustomField><required><deleteConstraint><lookupFilter><relationshipOrder>01<sharingModel>ControlledByParent<deleteConstraint>SetNullRestrictCascade<relationshipName><valueSet><valueSetName><valueSetDefinition><restricted>true</restricted>__cIndustry__gvs<controllingField><valueSettings><controllingFieldValue><valueName><picklist><picklistValues><controllingFieldValues><fullName><precision><scale><summaryForeignKey>ChildObject__c.MasterDetailField__c<summarizedField>ChildObject__c.FieldName__c<summarizedField><type><formula><![CDATA[ ... ]]><returnType><formulaTreatBlanksAs>BlankAsZeroBlankAsBlankscale ≤ precisionprecision ≤ 18<length>255</length><visibleLines>OrderGroupSelect