Create Salesforce custom fields. Use this skill when users request to create a field, add a field, or define a new custom field on any Salesforce object...
This skill creates
CustomFieldmetadata ONLY.NEVER create:
CustomObjectTranslationfiles (translations)objectTranslationsfiles- Any file with Hebrew labels inside XML
ALWAYS create:
CustomFieldXML files inforce-app/main/default/objects/<Object>/fields/- Labels must be in ENGLISH ONLY
NOTE: This skill is for creating FIELDS only, not Objects. For creating Objects, use the
create-objectskill.
Before creating any field, determine the target object type:
| Target Object Type | Field API Name Format | Example |
|---|---|---|
| Field on Standard Object (Account, Contact, Opportunity, etc.) | <PREFIX>_<FieldName>__c |
VST_Status__c |
Field on Custom Object (object name ends with __c) |
<FieldName>__c (NO prefix for the field) |
Status__c |
IMPORTANT: This rule applies to FIELD names only. Custom Objects themselves ALWAYS require the prefix (see create-object skill).
The PREFIX is defined in
copilot-instructions.md
When the user does not specify a field type, apply these defaults AUTOMATICALLY without asking:
| Missing Information | Default Value | Notes |
|---|---|---|
| Field Type | Text | Always default to Text |
| Text Length | 255 | Standard max for Text |
| Number Precision | 16 | Total digits including decimals |
| Number Scale | 0 | No decimal places by default |
ALWAYS include the required properties for each field type. Missing properties will cause deployment errors.
| Field Type | Required Properties | Example |
|---|---|---|
| Text | <length> (1-255) |
<length>255</length> |
| TextArea | <length> (max 131072) |
<length>32768</length> |
| LongTextArea | <length>, <visibleLines> |
<length>32768</length><visibleLines>5</visibleLines> |
| Html (Rich Text) | <length>, <visibleLines> |
<length>32768</length><visibleLines>10</visibleLines> |
| Number | <precision>, <scale> |
<precision>18</precision><scale>0</scale> |
| Currency | <precision>, <scale> |
<precision>18</precision><scale>2</scale> |
| Percent | <precision>, <scale> |
<precision>5</precision><scale>2</scale> |
| Checkbox | <defaultValue> |
<defaultValue>false</defaultValue> |
| Date | (none required) | - |
| DateTime | (none required) | - |
| Picklist | <valueSet> |
See Picklist template below |
| Lookup | <referenceTo>, <relationshipName> |
See Lookup template below |
<length> for Text fields<type>Html</type> instead of RichTextAreaISPICKVAL(field, "value") not field = "value"force-app/main/default/objects/<ObjectAPIName>/fields/<FieldAPIName>.field-meta.xml
<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>{FieldAPIName}</fullName>
<label>{FieldLabel}</label>
<type>Text</type>
<length>255</length>
</CustomField>
Request: "Create a Status field on Account"
Result:
VST_Status__c (with prefix)force-app/main/default/objects/Account/fields/VST_Status__c.field-meta.xml<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>VST_Status__c</fullName>
<label>Status</label>
<type>Text</type>
<length>255</length>
</CustomField>
Request: "Create an EndDate field on VST_Visit__c"
Result:
EndDate__c (NO prefix for the FIELD - because it's on a custom object)force-app/main/default/objects/VST_Visit__c/fields/EndDate__c.field-meta.xml<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>EndDate__c</fullName>
<label>End Date</label>
<type>Date</type>
</CustomField>
Before creating a field, verify the target object exists in the project:
force-app/main/default/objects/<ObjectAPIName>/<ObjectAPIName> was not found in the project."Example response when object not found:
The object
VST_Visit__cwas not found in the project. Please create the object first or specify a different object.
Before creating a field:
<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>IsActive__c</fullName>
<label>Is Active</label>
<defaultValue>false</defaultValue>
<type>Checkbox</type>
</CustomField>
<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>Quantity__c</fullName>
<label>Quantity</label>
<precision>18</precision>
<scale>0</scale>
<type>Number</type>
</CustomField>
<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>Description__c</fullName>
<label>Description</label>
<length>32768</length>
<type>Html</type>
<visibleLines>10</visibleLines>
</CustomField>
<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>Status__c</fullName>
<label>Status</label>
<type>Picklist</type>
<valueSet>
<valueSetDefinition>
<sorted>false</sorted>
<value>
<fullName>Draft</fullName>
<default>true</default>
<label>Draft</label>
</value>
<value>
<fullName>Active</fullName>
<default>false</default>
<label>Active</label>
</value>
<value>
<fullName>Closed</fullName>
<default>false</default>
<label>Closed</label>
</value>
</valueSetDefinition>
</valueSet>
</CustomField>
<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>Account__c</fullName>
<label>Account</label>
<type>Lookup</type>
<referenceTo>Account</referenceTo>
<relationshipName>RelatedRecords</relationshipName>
<relationshipLabel>Related Records</relationshipLabel>
</CustomField>
NOTE: When comparing Picklist fields in formulas, ALWAYS use ISPICKVAL() function!
<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>IsReady__c</fullName>
<label>Is Ready</label>
<type>Checkbox</type>
<formula>ISPICKVAL(Status__c, "Active")</formula>
<formulaTreatBlanksAs>BlankAsZero</formulaTreatBlanksAs>
</CustomField>
WRONG (will cause error): Status__c = "Active"
CORRECT: ISPICKVAL(Status__c, "Active")