Logo: Custom Metadata Types

Custom Metadata Types

Communautéit
PranavNagrecha
custom-metadata-types

Use when designing deployable Salesforce configuration with Custom Metadata Types, especially when choosing between CMTs, Custom Settings, and Custom Objects, protecting packaged defaults, or exposing config to Apex, Flow, and formulas. Triggers: 'custom metadata vs custom settings', 'deployable config', 'protected custom metadata', 'feature flags in Salesforce'. NOT for hierarchical Custom Settings resolution, getInstance/getValues, or their SOQL cost — use admin/custom-metadata-types-and-settings. NOT for high-churn transactional or user-managed business records — use admin/object-creation-and-design. NOT for secrets — use integration/named-credentials-setup. More trigger keywords: __mdt, CustomMetadata .md file, customMetadata folder, getInstance, getAll, xsi:type, visibility PackageProtected, MetadataRelationship, EntityDefinition field, $CustomMetadata.

Iwwersiicht

EditeurPranavNagrecha
RepositoryAwesomeSalesforceSkills
Skill-Nummcustom-metadata-types
Stären
26
Forks
5
Matgeliwwert Dateien
7
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 7 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    PranavNagrecha huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Custom Metadata Types an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/PranavNagrecha/AwesomeSalesforceSkills/tree/main/skills/admin/custom-metadata-types
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/PranavNagrecha/AwesomeSalesforceSkills.git /tmp/AwesomeSalesforceSkills
mkdir -p .claude/skills
cp -r /tmp/AwesomeSalesforceSkills/skills/admin/custom-metadata-types .claude/skills/custom-metadata-types
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Custom Metadata Types an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Custom Metadata Types automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Custom Metadata Types net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

Use this skill when the org needs configuration that behaves like software, not like business data. Custom Metadata Types are the right answer when values should be versioned, deployed, packaged, and read consistently by Apex, Flow, and formulas without hardcoding environment-specific behavior.


Before Starting

Gather this context before you decide on the storage model:

  • Who changes the values, and how often do they change in production?
  • Do the records need to travel through source control, packaging, or deployment pipelines?
  • Are the values regular configuration, per-user overrides, reportable business data, or secrets such as tokens and passwords?

Questions to Ask Before Configuring

Ask these before creating the type. Each one decides an element you will have to write into the XML, and an LLM that skips them produces a type that deploys and then behaves wrongly in the target org.

AskWhy it mattersWhat a good answer adds
"Will this type ever ship in a managed package?"visibility is Public by default and Protected / PackageProtected only mean anything inside a managed packageThe visibility value, chosen deliberately rather than defaulted
"Which records, if any, must the subscriber be unable to read or change?"Record-level protected is a one-way door: a protected record's developer name cannot change after release and the subscriber cannot create records of a protected typeThe per-record protected flag and a note of what is now frozen
"Which fields will the subscriber be allowed to edit after install?"fieldManageability (Locked / DeveloperControlled / SubscriberControlled) is set per field and is valid only on custom metadata type fieldsA field-by-field manageability decision instead of a silent default
"Can any field value exceed 255 characters?"getAll() and getInstance() truncate every field at 255 characters; only SOQL returns the whole valueThe Apex access pattern, and a decision to move long values elsewhere
"Who reads these records at runtime — Apex, Flow, formulas, or an external system?"A reader on the Enterprise WSDL or SOAP API is cut off by enableAdvancedCMTSecurity, and every non-admin reader needs the type enabled in a permission setThe consumer list and the customMetadataTypeAccesses entries to ship with it
"Does a field need to point at an object or a field on that object?"That is a MetadataRelationship field to EntityDefinition or FieldDefinition, not a Text field holding an API nameThe relationship field definition and its metadataRelationshipControllingField where required
"Who deploys this, and do they hold both permissions?"Creating the type needs "Author Apex"; creating records needs "Customize Application"A deployment identity that can land the whole package, not half of it

What a proper configuration adds over just creating the type in Setup: the records deploy as metadata alongside the code that reads them, the visibility and manageability choices are deliberate rather than defaulted, and every runtime consumer — Apex, Flow, formula, and non-admin user — has been proven to read the values before release.


Core Concepts

Custom Metadata Types are metadata records, not transactional rows. That distinction matters because metadata belongs in source control, deployments, and packaging workflows. If the requirement is "same logic, different environment-safe configuration," CMT is usually the best fit. If the requirement is "users update this every day and report on it," it is usually the wrong fit.

Deployable Configuration, Not User Data

Use CMT when the value should move between sandboxes, scratch orgs, packaging orgs, and production in a controlled way. This is why routing rules, thresholds, feature toggles, and endpoint path fragments fit well. A Custom Object is better when admins or business users need to add and edit records frequently through the UI and treat the records like business data.

CMT, Custom Settings, And Custom Objects Solve Different Problems

Hierarchy Custom Settings still matter when behavior varies by user or profile and the override must be cheap to change in production. Custom Objects fit reportable, user-managed records. CMT fits org-level or package-level configuration that should be promoted like code. The wrong decision usually comes from optimizing for today's convenience instead of the future deployment model.

Protection And Visibility Are Packaging Concerns

Protected custom metadata is useful when a managed package needs internal defaults that subscriber admins should not read or edit. It is not a general-purpose data security boundary for the same org. If the real need is secret management, use Named Credentials or another supported secret store, not public CMT records with masked labels.

The Type Is An Object; The Records Are Separate Components

Three components, three package.xml entries, and one naming asymmetry that causes most first-deploy failures.

Componentpackage.xml <name>Member syntaxFile
The typeCustomObjectRouting_Rule__mdtobjects/Routing_Rule__mdt/Routing_Rule__mdt.object-meta.xml
A fieldCustomFieldRouting_Rule__mdt.Threshold__cobjects/Routing_Rule__mdt/fields/Threshold__c.field-meta.xml
A recordCustomMetadataRouting_Rule.EMEA_HighcustomMetadata/Routing_Rule.EMEA_High.md-meta.xml

The type carries the __mdt suffix; the record name drops it. Type-level settings live on the CustomObject (label, pluralLabel, description, visibility); record-level settings live on the CustomMetadata (label, description, protected, and one <values> block per populated field). Field values are typed with an xsi:type attribute that must match the field definition. Full deployable XML is in references/metadata-examples.md.

Runtime Access Is Easy; Runtime Mutation Is Not

Apex, Flow, and formulas can read CMT records cleanly, but normal business-transaction DML is not the operating model. That is by design. CMT is meant to stabilize configuration, not to become a hidden editable database.


Common Patterns

Metadata-Driven Routing Or Threshold Rules

When to use: A Flow or Apex service needs environment-safe rules such as queue routing, score thresholds, or feature switches.

How it works: Model the rules in a CMT, query them by stable keys such as DeveloperName, and keep the business logic reading configuration instead of embedding IDs and values in code.

Why not the alternative: Hardcoded IDs, labels, or endpoints create deployment drift and sandbox-specific breakage.

Packaged Defaults Plus Subscriber-Safe Extensions

When to use: A managed package needs safe defaults but also wants limited subscriber configuration.

How it works: Keep vendor-owned defaults protected where appropriate, expose only the fields and records that should be subscriber-editable, and separate secrets into Named Credentials.

Why not the alternative: Public metadata for internal defaults leaks implementation details and invites unsupported edits.

Deliberate Migration Off Custom Settings

When to use: Existing org logic reads List or Hierarchy Custom Settings even though the values should really be source-controlled and deployed.

How it works: Inventory the settings, separate true per-user overrides from deployable org config, move the stable org config into CMT, and update Apex/Flow lookups to use metadata keys instead of record IDs.


Decision Guidance

SituationRecommended ApproachReason
Org-wide rules must deploy through Git and CI/CDCustom Metadata TypeConfiguration behaves like metadata and should be promoted with releases
Behavior varies by user or profileHierarchy Custom SettingPer-user and per-profile overrides are the primary requirement
Admins need frequent UI editing and reporting on the recordsCustom ObjectThe records are business data, not release-managed configuration
The value is a password, token, or client secretNamed Credential or supported secret storeCMT is not the right secret boundary
Packaged logic needs internal defaults in a managed packageProtected Custom Metadata where appropriateKeeps package-owned config private while remaining deployable

Recommended Workflow

  1. Confirm CMT is the right store — run the Decision Guidance table above against the answers to ## Questions to Ask Before Configuring. If the answer is a per-user or per-profile override, stop here and use admin/custom-metadata-types-and-settings; if it is a secret in an unpackaged org, use integration/named-credentials-setup.
  2. Fill in the design worksheet — templates/custom-metadata-types-template.md captures the type API name, the key strategy, visibility, per-field fieldManageability, and the runtime access plan for Apex, Flow, and formulas.
  3. Write the type and its fields — copy the shapes from references/metadata-examples.md: the CustomObject with label, pluralLabel, visibility, then one field-meta.xml per field. Choose a MetadataRelationship field over a Text field holding an API name wherever the value points at an object or a field.
  4. Write the records — one .md-meta.xml per record in customMetadata/, each <values> block carrying the correct xsi:type, and <value xsi:nil="true"/> wherever you mean null rather than "leave unchanged".
  5. Run the checker — python3 skills/admin/custom-metadata-types/scripts/check_custom_metadata_types.py --manifest-dir force-app/main/default. It flags records referencing fields that do not exist on the type, empty labels, secret-shaped field names on public types, environment-specific hosts in record values, and DML against __mdt in Apex.
  6. Deploy type, fields, and records in one manifest, then verify — sf project deploy validate first; then confirm with the SOQL and the getInstance assertion at the end of references/metadata-examples.md, and re-run the query as a non-admin user to prove the permission-set custom metadata type access shipped with it.
  7. Read references/gotchas.md before release — the 255-character truncation, the omitted-<values> behaviour, and the three separate protection switches all change what you ship, not just how you test it.

Review Checklist

Run through these before marking work in this area complete:

  • The requirement is truly configuration, not business data with reporting and CRUD needs.
  • The chosen storage model matches the deployment and ownership model, not just developer convenience.
  • Stable keys such as DeveloperName are part of the lookup contract.
  • No secrets, passwords, or tokens are being stored in public CMT records.
  • Apex, Flow, and formulas read metadata intentionally and do not depend on environment-specific IDs.
  • Any packaging visibility choice is documented, especially for protected defaults.
  • visibility on the type and protected on each record were chosen deliberately, not left at the default.
  • Every <values> block has an xsi:type matching its field, and every field meant to be null uses xsi:nil.
  • Any field that can exceed 255 characters is read with SOQL, not getAll() / getInstance().
  • The permission set or profile that non-admin readers hold enables this custom metadata type.
  • The type, its fields, and its records deploy from one manifest, and the deploy was validated before the real run.

Salesforce-Specific Gotchas

Non-obvious platform behaviors that cause real production problems:

  1. CMT records are metadata, not runtime DML targets - teams design them like editable rows and then discover the write path does not fit normal transaction logic.
  2. Protected metadata is a package boundary, not an org security model - it helps managed-package encapsulation but does not replace proper secret handling or field security strategy.
  3. DeveloperName becomes part of the contract - once code, Flow, or formulas key off metadata names, renaming records casually creates breakage.
  4. A deployable model is slower to change by design - if operations needs hourly production edits by non-release users, the wrong storage type may have been chosen.
  5. The cached accessors truncate at 255 characters - getAll() and getInstance() cut every field; only SOQL returns the full value, and SOQL against __mdt is unlimited per transaction.
  6. Leaving a <values> block out does not clear the field - it stays at its previous value on an update and lands as null on a first deploy; xsi:nil is the only explicit clear.
  7. visibility and protected are two switches, not one - plus PackageProtected, which the Metadata API guide names as the value for securing API keys and tokens inside a managed package.
  8. A __mdt object can be unreadable without any sharing rule - PermissionSetCustomMetadataTypeAccess gates record readability per type from API 47.0, and enableAdvancedCMTSecurity hides values from the SOAP API org-wide.

Deeper treatment, with the source for each, in references/gotchas.md.


Output Artifacts

ArtifactDescription
Configuration storage decisionRecommendation for CMT vs Custom Setting vs Custom Object vs Named Credential
Metadata modelSuggested type, fields, keys, and visibility model for the configuration
Refactor findingsConcrete issues such as hardcoded IDs, public secrets, or wrong storage fit
Deployable metadataobjects/<Type>__mdt/ with its fields/, customMetadata/<Type>.<Record>.md-meta.xml, and the package.xml carrying all three

Reference Files

FileRead it when
references/metadata-examples.mdWriting or reviewing the deployable XML for the type, its fields, its records, and the package.xml
references/gotchas.mdTen platform behaviours that change what you ship — truncation, xsi:nil, the protection switches, permission-set access
references/examples.mdWorking through a routing-rules or packaged-defaults scenario end to end
references/well-architected.mdJustifying the storage choice against Operational Excellence, Reliability, and Security, or citing the official sources
references/llm-anti-patterns.mdSelf-checking generated output for DML on __mdt, wrong storage choice, or missing no-code access paths

Related Skills

  • admin/custom-metadata-types-and-settings - the Custom Settings side of the comparison: hierarchical resolution, getValues/getInstance, and their governor-limit cost.
  • apex/custom-metadata-in-apex - use when the storage decision is made and the main question is Apex access and caching patterns.
  • apex/apex-dml-patterns - why standard DML never applies to __mdt and what the Metadata.DeployContainer path costs instead.
  • admin/change-management-and-deployment - use when the release process and environment promotion model are the harder problem.
  • devops/unlocked-package-development - packaging the type and its records, where visibility and record protected start to matter.
  • admin/assignment-rules - a common consumer: routing configuration modelled as CMT records instead of hardcoded queue Ids.
  • admin/object-creation-and-design - when the records turn out to be business data that users edit and report on.
  • integration/named-credentials-setup - where endpoint hosts and credentials belong instead of CMT fields.
  • admin/process-automation-selection - use when Flow or Apex design is the main decision and CMT is only one part of the solution.

Matgeliwwert Dateien

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill Custom Metadata Types?

Use when designing deployable Salesforce configuration with Custom Metadata Types, especially when choosing between CMTs, Custom Settings, and Custom Objects, protecting packaged defaults, or exposing config to Apex, Flow, and formulas. Triggers: 'custom metadata vs custom settings', 'deployable config', 'protected custom metadata', 'feature flags in Salesforce'. NOT for hierarchical Custom Settings resolution, getInstance/getValues, or their SOQL cost — use admin/custom-metadata-types-and-settings. NOT for high-churn transactional or user-managed business records — use admin/object-creatio...

Firwat Custom Metadata Types op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Custom Metadata Types besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Custom Metadata Types an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/PranavNagrecha/AwesomeSalesforceSkills/tree/main/skills/admin/custom-metadata-types an. TypingMind liest d'Datei SKILL.md, bëndelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Custom Metadata Types benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Custom Metadata Types benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Custom Metadata Types domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Custom Metadata Types gratis?

PranavNagrecha huet de Skill op GitHub publizéiert. Kuckt am Repository no de Lizenzbedéngungen. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇