Salesforce Developer Interview Question

When would you use custom metadata types instead of custom settings?

What the interviewer is probing, how to structure your answer, and a spoken example you can adapt.

Quick answer

Use custom metadata types for configuration that should deploy with your code, such as mappings, thresholds or feature switches, because their records are metadata and move through sandboxes and packages like any other component. Use hierarchy custom settings when values must differ by user or profile, or when the values genuinely differ per environment. Both are cached and cheap to read, so neither needs a SOQL query per lookup in normal use.

Why interviewers ask this

Hard coded values are a common source of painful deployments, and the interviewer wants to see that you pick the right configuration mechanism. The key distinction is that custom metadata records deploy as metadata, while custom setting records are data that must be loaded separately in each org. They also listen for hierarchy settings as the tool for per user or per profile values, which custom metadata does not provide.

How to structure your answer

  • Explain the deployment difference between the two.
  • Give typical uses for custom metadata types.
  • Give typical uses for hierarchy custom settings.
  • Mention reading them efficiently and testing with them.

Example answer

Spoken example, first person

The deciding question for me is whether the values should travel with the code. Custom metadata type records are metadata, so a mapping of product codes to tax categories, or a threshold used in an approval rule, deploys through our pipeline with the Apex that uses it. The values are version controlled, and every sandbox gets the same configuration without anyone remembering to load data. Custom settings are different. Their records are data, so they have to be created separately in each org, which suits values that genuinely differ per environment. Where I still reach for custom settings is the hierarchy type, which lets me set an org default and override it for a profile or a single user, for example a switch that turns off a trigger for the integration user during a data load. Both are cached, so reading them in Apex does not use a query each time. In tests I avoid depending on real configuration records, by putting the lookup behind a small class I can stub.

Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.

See how it works

Follow-up questions to expect

  • How would you test code that depends on custom metadata records?
  • Could you update custom metadata records from Apex at runtime?
  • How would you build a switch that turns off automation for one user?

Related salesforce developer questions

Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.

Predict my questions

Rehearse the hard questions before they are asked

Practise with a live copilot, then walk in ready. A $29 Session Pass gets you through the interview with no subscription and no lock-in.

Get GhostPilot