OBLYTECH Logo
OBLYTECH Logo

Drift Detection Routine for Salesforce Metadata

Salesforce metadata drift detection is a scheduled comparison between production configuration and the source of record, usually a version-controlled repository. Each difference gets classified, then a named owner either adopts the change into the source of record or reverts it in production. The routine surfaces edits that skipped the release process.

Why production configuration drifts from the source of record

Drift usually starts with a reasonable shortcut. An admin fixes a broken page layout during a live incident, a developer adjusts a validation rule to unblock a data load, or a business user changes a picklist value that a report depends on. Each change may be correct on its own. The trouble is that the repository still holds the old version, so a later deployment built from the repository can overwrite the fix or bring back a problem that was already solved.

Drift also builds up across people. Two admins working in the same org on different days can each make a small edit that conflicts with the other’s, and neither sees the conflict because neither looks at the whole picture. A scheduled comparison puts those differences in one list where they can be read together.

How to set up the baseline and comparison scope

Pick one source of record

Choose a single place that counts as correct. Many teams use a version-controlled repository that holds the metadata files deployed to production. If you keep the baseline in a sandbox, record which sandbox it is and who approves changes to it. A sandbox refresh replaces the sandbox contents with a copy of production, so any baseline stored there needs a check against the repository after each refresh. Refresh timing is a separate decision, so review the sandbox refresh planning guidance before you set the schedule.

Decide which metadata types belong in scope

In most implementations, start with the components that change how users and integrations behave: automation, security settings, page and record layouts, and the fields that feed reports. Add other types after the first few cycles run cleanly. A narrow scope gives a readable result. A broad scope produces a list nobody reads, and the changes that matter get buried.

Write the boundary down before the first run. Note which managed packages, generated files and namespaces are excluded and why. A comparison that flags the same excluded items each week teaches people to skim the report, and then they miss the real differences.

Running the comparison on a regular cycle

The right cadence depends on how often your org changes. Teams that release weekly often run the comparison before each release and once a week in between. Slower teams can run it monthly. Pick a cadence you can keep, because a check that runs twice and stops tells nobody anything.

Each cycle follows the same sequence:

  1. Retrieve the current metadata from production with the tool your team already uses for deployments, and confirm the retrieval finished without partial results.
  2. Compare the retrieved files against the source of record and export the list of differences to a shared location.
  3. Remove expected noise, such as formatting or ordering differences that do not change behavior, and write down the rule you applied so the filter stays visible.
  4. Group the remaining differences by component type and by the person who last changed each one, if the change history shows that.
  5. Send each group to its owner before the review meeting so the discussion starts from the evidence.

If the retrieval is large, check your org’s processing limits before you schedule it, starting with the governor limits for admins guidance as the starting point.

Run the first cycle as a dry run with no changes made in production. The first list is usually long, and it shows how the process behaves: how many items the filter removes, how long owners take to reply, and which groups have no named owner yet. Use those results to adjust scope before the second cycle, not after owners have already started editing production to clear the report.

Classifying each difference and assigning a named owner

Every difference needs one of four outcomes. Classify it before anyone edits anything, because a change that looks wrong can be the one the business asked for.

  • Adopt: the production change is correct. Update the source of record so the next deployment keeps it.
  • Revert: the production change is wrong or unapproved. Restore the source-of-record version through the normal release path.
  • Defer: the owner needs more information. Record the open question and a review date.
  • Accept as exception: the difference is intentional and should stay out of future reports. Record the reason and who approved it.

The named owner decides, not the person who ran the comparison. Assign owners by area. A security change goes to whoever owns access design, and a flow change goes to the person accountable for that process. When an area has no owner, the difference goes to the release lead and the gap becomes a backlog item. For access changes, read the permission set design for small teams guidance before deciding, so the decision reflects the roles people actually hold.

Reverting changes without breaking integrations

A revert is a deployment, so treat it like one. Before restoring an older version, list the integrations, reports and users that depend on the current production behavior. A rule that looks like a stray edit may be what keeps bad data from reaching an external system. Walk that list through with the integration owner before the revert is scheduled. The guidance on validation rule changes that leave integrations intact covers those checks in more depth.

Emergency fixes need their own rule. When a production change was made to stop an outage, the owner decides within the cycle whether to adopt it or revert it, and the decision goes into the log with the incident reference. Leaving that change in place until the next scheduled run can let an unapproved change run for a long time.

Recording decisions so the next run stays readable

Keep a decision log with one line per difference: component name, outcome, owner, date and reason. Store it next to the comparison output. A spreadsheet with those five columns is enough for a small org; what matters is that every cycle fills in the same columns. The log stops the same change from being flagged, debated and forgotten in each cycle. Review it at the start of each run and remove entries whose changes have reached the source of record.

Track two numbers over time: how many differences each run produces and how many reach a decision before the next run. A growing backlog of open items usually means owners need more time or the scope is too broad. It does not necessarily mean the org is in worse shape than before.

When the same component drifts in consecutive cycles, treat that as a process problem. Someone is editing production for a reason the release path does not cover. Find the reason and fix the path, otherwise the report keeps flagging the same item.

For help planning this work, see Salesforce implementation.

Questions about running drift checks on a Salesforce org

What tooling do I need to start?

The method matters less than the rules around it. Pick a comparison approach your team can run the same way each cycle, and confirm that it retrieves all components in your scope before you trust its output. Confirm the edition and release requirements for that approach against your own org before you commit to it.

How long should a deferred difference stay open?

Set a review date within one release cycle. If the owner has not decided by then, escalate to the release lead and record the escalation in the log. An open item with no date tends to stay open for a long time.

What do I do with a difference I cannot explain?

Mark it as deferred, attach the retrieval date and the component name, and ask the people who had access during that period. Do not revert it until the owner has seen it, because the change may be an emergency fix the business still depends on.

Does drift detection replace change control?

No. It checks whether the change process held. It surfaces the edits that bypassed the process so the team can learn from them. Changes still need review and approval on the normal release path before they reach production.

Should drift checks cover access settings?

Include them if your org manages access through those components, and give them their own owner review. In most teams, access changes carry more risk than layout changes, so review them first in each cycle. Confirm with the access design owner which components are under source control before adding them to scope.