
Generating Custom Object
Generate and validate Salesforce Custom Object metadata XML so Metadata API deploys succeed on sharing, name fields, and Master-Detail rules.
Install
npx skills add https://github.com/forcedotcom/sf-skills --skill generating-custom-objectWhat is this skill?
- Mandatory constraints for CustomObject metadata before XML output to avoid Metadata API deployment errors
- Covers sharing models, name fields, validation rules, and Master-Detail relationship troubleshooting
- Specifies `.object-meta.xml` filename convention with API name as filename (e.g. Vehicle__c)
- Tier 1 syntactic essentials table for required elements and deployment verification
- Triggers on create/generate/validate custom object requests and sharing-model deployment failures
Adoption & trust: 757 installs on skills.sh; 513 GitHub stars; 3/3 security scanners passed (skills.sh audits).
Recommended Skills
Azure Deploymicrosoft/azure-skills
Azure Preparemicrosoft/azure-skills
Azure Storagemicrosoft/azure-skills
Azure Validatemicrosoft/azure-skills
Appinsights Instrumentationmicrosoft/azure-skills
Azure Resource Lookupmicrosoft/azure-skills
Journey fit
Primary fit
Build → Integrations fits Salesforce metadata work that extends the CRM data model before apps and automations consume new objects. CustomObject `.object-meta.xml` generation is platform integration metadata, not generic frontend or ship-time testing.
Common Questions / FAQ
Is Generating Custom Object safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Generating Custom Object
## When to Use This Skill Use this skill when you need to: - Create new custom objects - Generate custom object metadata XML - Configure object sharing and security settings - Set up object features and capabilities - Troubleshoot deployment errors related to custom objects ## Specification ## 1. Overview and Purpose This document defines the mandatory constraints for generating CustomObject metadata XML (`.object-meta.xml` file). The agent must verify these constraints before outputting XML to prevent Metadata API deployment errors. **File extension:** `.object-meta.xml` --- ## 2. Syntactic Essentials (Tier 1) The following constraints must be true for the XML body to deploy successfully. **Note:** The API Name (fullName) is NOT a tag; it is the filename (e.g., `Vehicle__c.object-meta.xml`). ### Required Elements | Element | Requirement | Notes | |---------|-------------|-------| | `<label>` | Required | Singular UI name | | `<pluralLabel>` | Required | Plural UI name | | `<sharingModel>` | Required | See Sharing Model Rules below | | `<deploymentStatus>` | Required | Always set to `Deployed` | | `<nameField>` | Required | Primary record identifier (requires `<label>` and `<type>`) | | `<visibility>` | Required | Always set to `Public` | ### Sharing Model Rules **Default:** Set `<sharingModel>` to `ReadWrite`. **Exception:** If this object contains a Master-Detail relationship field, `<sharingModel>` MUST be `ControlledByParent`. **Decision Logic:** - IF object has NO Master-Detail field → use `ReadWrite` - IF object has Master-Detail field → use `ControlledByParent` - IF a Master-Detail field is being added to an existing child object → that existing object's `<sharingModel>` must also be updated to `ControlledByParent` **❌ INCORRECT** — Will cause error: `Cannot set sharingModel to ReadWrite on a CustomObject with a MasterDetail relationship field` ```xml <CustomObject xmlns="http://soap.sforce.com/2006/04/metadata"> <label>Order Line Item</label> <pluralLabel>Order Line Items</pluralLabel> <sharingModel>ReadWrite</sharingModel> <!-- WRONG: Object has a M-D field --> <deploymentStatus>Deployed</deploymentStatus> </CustomObject> ``` **✅ CORRECT:** ```xml <CustomObject xmlns="http://soap.sforce.com/2006/04/metadata"> <label>Order Line Item</label> <pluralLabel>Order Line Items</pluralLabel> <sharingModel>ControlledByParent</sharingModel> <!-- CORRECT --> <deploymentStatus>Deployed</deploymentStatus> </CustomObject> ``` --- ## 3. Smart Defaults & Decision Logic (Tier 2) The agent must choose which features to enable based on the object's intended use case. ### A. The Name Field Decision | Type | When to Use | Additional Requirements | |------|-------------|------------------------| | **Text** | Default for human-named entities (Projects, Locations, Teams) | None | | **AutoNumber** | Use for transactions, logs, or IDs (Invoices, Requests, Tickets) | Must include `<displayFormat>` (e.g., `INV-{0000}`) and `<startingNumber>1</startingNumber>` | **Text Name Field Example:** ```xml <nameField> <label>Project Name</label> <type>Text</type> </nameField> ``` **AutoNumber Name Field Example:** ```xml <nameField> <label>Invoice Number</label> <type>AutoNumber</type> <displayFormat>INV-{0000}</displayFormat> <startingNumber>1</startingNumber> </nameField> `