forcedotcom/sf-skills2 files

Platform Custom Field Generate

Use when users create, generate, or validate Salesforce Custom Field metadata. Trigger on custom fields, field types, Roll-Up Summary, Master-Detail/Lookup relationships, formula fields, picklists, dependent (controlling) picklists, referencing a value set from a field, or scoping picklist values per record type; also field deployment errors, including a record type that won't deploy without a business process. DO NOT TRIGGER for creating/customizing the value set itself — a new GlobalValueSet or a StandardValueSet catalog like Industry — use platform-value-set-generate; this skill covers the field that references a value set, not the value set definition.

Specification
Skill ID
forcedotcom/sf-skills/platform-custom-field-generate
Publisher
forcedotcom
Repository
sf-skills
Installs
0
Files
2
Synced
Sep 23, 2026
How to use it

Open any RiverX project, open the Skills panel in the chat, and search for this identifier. The files are fetched from the source repository at install time.

forcedotcom/sf-skills/platform-custom-field-generateInstalls these files
  • SKILL.md
  • references/advanced-picklists.md

What this skill tells the agent

Salesforce Custom Field Generator and Validator

Overview

Generates and validates Salesforce CustomField metadata XML, with special handling for the highest-failure-rate types — Roll-Up Summary and Master-Detail. The agent must verify the constraints below before outputting XML to prevent Metadata API deployment errors.


1. Universal Mandatory Attributes

Every generated field must include these tags:

AttributeRequirementNotes
<fullName>RequiredField name only: derive from <label> — capitalize each word, replace spaces with _, append __c. Must start with a letter. E.g., label Total Contract Value → Total_Contract_Value__c. This rule is for the FIELD name. Picklist VALUE `<fullName>` is different — keep it exactly as the user spelled it, spaces and all, no `__c` (e.g. Closed Won, NOT Closed_Won). See `references/advanced-picklists.md` (ref §3).
<label>RequiredThe UI name (Title Case)
<description>Always includeExplain the business reason why this field exists.
<inlineHelpText>Always includeActionable end-user guidance that adds value beyond the label (e.g., "Enter the value in USD including tax", not "The amount").

<description> and <inlineHelpText> are mandatory even though the Metadata API does not enforce them — omitting them yields low-quality metadata.

File path (SFDX source format): save each field as force-app/main/default/objects/<Object>/fields/<FieldName>__c.field-meta.xml, where <Object> is the object's API name (Account, Opportunity, or a custom Inventory_Item__c). A correct XML at the wrong path is never seen by the Metadata API.

External ID Configuration

Trigger: If the user mentions "integration," "importing data," "external system ID," or "unique key from [System Name]," set <externalId>true</externalId>.

Applicable Types: Text, Number, Email


2. Precision, Scale, and Length Rules

To ensure deployment success, follow these mathematical constraints:

Precision vs. Scale Rules

  • precision is the total digits; scale is the decimal digits
  • Rule: precision ≤ 18 AND scale ≤ precision
  • Calculation: Digits to the left of decimal = precision - scale

The "Fixed 255" Rule

TextArea: do NOT include `<length>` — the API fixes it at 255 implicitly and rejects an explicit value ("Can not specify 'length' for a CustomField of type TextArea"). The field needs only <fullName>, <label>, and <type>TextArea</type>.

Visible Lines

Mandatory for Long/Rich text and Multi-select picklists to control UI height.


3. Field Data Types

3.1 Simple Attribute Types

Type<type> ValueRequired Attributes
Auto NumberAutoNumberdisplayFormat (must include {0}), startingNumber
CheckboxCheckboxDefault defaultValue to false
DateDateNo precision/length required
Date/TimeDateTimeNo precision/length required
EmailEmailBuilt-in format validation
Lookup RelationshipLookupreferenceTo, relationshipName, deleteConstraint
Master-Detail RelationshipMasterDetailreferenceTo, relationshipName, relationshipOrder
NumberNumberprecision, scale
CurrencyCurrencyDefault precision: 18, scale: 2
PercentPercentDefault precision: 5, scale: 2
PhonePhoneStandardizes phone number formatting
PicklistPicklistvalueSet containing EITHER valueSetDefinition (inline) OR valueSetName (reference); restricted (see "Picklist restricted default" below; advanced cases in §3.4)
TextTextlength (Max 255)
Text AreaTextAreaNone — do NOT include <length>; the API fixes length at 255 implicitly
Text (Long)LongTextArealength, visibleLines (default 3)
Text (Rich)Htmllength, visibleLines (default 25)
TimeTimeStores time only (no date)
URLUrlValidates for protocol and format

3.2 Computed & Multi-Value Types

Type<type> ValueRequired Attributes
FormulaResult type (e.g., Number)formula, formulaTreatBlanksAs
Roll-Up SummarySummarySee Section 5 for complete requirements
Multi-Select PicklistMultiselectPicklistvalueSet, visibleLines (default 4)

3.3 Specialized Types

Type<type> ValueRequired Attributes
GeolocationLocationscale, displayLocationInDecimal

Picklist restricted default

Always set `<restricted>true</restricted>` inside <valueSet> unless the user explicitly says the picklist should accept custom values not in the admin-defined list (e.g. "unrestricted"/"open"). Restricted sets are capped at 1,000 total values (active + inactive). Minimal inline shape:

<valueSet>
  <restricted>true</restricted>
  <valueSetDefinition>
    <sorted>false</sorted>
    <value><fullName>Option_A</fullName><default>false</default><label>Option A</label></value>
  </valueSetDefinition>
</valueSet>

3.4 Advanced Picklists

The inline <valueSetDefinition> above is the simple case. Full rules and worked correct/incorrect examples for everything below are in `references/advanced-picklists.md` — load it for any non-trivial picklist. Section numbers in parentheses below (e.g. "ref §1") point to that reference file, not to this skill. The hard rules:

  • Value-set reference (ref §1). A <valueSet> holds EITHER <valueSetName> (reference) OR <valueSetDefinition> (inline) — never both. Reference by the bare developer name — Standard set Industry, GlobalValueSet Priority_Levels with NO `__gvs` and no __c (the __gvs suffix is org-storage display only; the Metadata API uses the bare name). A value-set-backed field is <restricted>true</restricted>. Creating the value set is the platform-value-set-generate skill's job; this one only references it.
  • Value-name fidelity (ref §3). A picklist value's <fullName>/<label> keep the user's exact text including spaces (Closed Won, never Closed_Won). The space→_ + __c rule is for the FIELD name only.
  • Dependent picklists (ref §2). Use the modern API 38.0+ form: <controllingField> + one <valueSettings> (<controllingFieldValue>+<valueName>) per pair; never the legacy <picklist>/<picklistValues>/<controllingFieldValues> tags. Both controlling and dependent fields MUST be <restricted>true</restricted>, even if the request doesn't say so.
  • Enhanced value attributes (ref §3). <value> entries also accept <color> (hex, leading #), <isActive> (false retires a value), and a value-level <description>.
  • Scoping a picklist to a record type (ref §5). Per-record-type value visibility lives on the RecordType (<picklistValues>), not the field. The RecordType file carries its own <fullName> (bare developer name). First decide if the object needs a BusinessProcess: only Opportunity / Lead / Case / Solution require one — they won't deploy without a <businessProcess> (Required field is missing: businessProcess), even when only a custom picklist is filtered. There you emit two coupled files: the businessProcesses/<Name>.businessProcess-meta.xml file AND a matching <businessProcess><Name></businessProcess> inside the <RecordType> (after <active>, before <picklistValues>; the <fullName> in the BP file is bare, never object-qualified). *Custom objects (`__c`) and all other standard objects (Account, Contact, …) need NO BusinessProcess — emit the RecordType alone; do not invent one. Scope limit:**

More from forcedotcom

Use this skill in a project

Open any RiverX project, search the Skills panel for forcedotcom/sf-skills/platform-custom-field-generate, and install it in one click.

Use this skill