The independent daily for Salesforce admins, developers and architects

Curated by Abhinav (opens in a new tab)

Must-read

Where the Metadata API deployment result keeps its errors and coverage warnings (opens in a new tab)

You will know which fields of the deployment result hold component errors, test failures and coverage warnings, and why a deployment can fail with an empty componentFailures list.

Why read this

The post also gives a checklist for diagnosing a failed deployment.

  1. Set includeDetails to true
  2. Check componentFailures
  3. Check runTestResult failures
  4. Check runTestResult codeCoverageWarnings
Where to look when a deployment fails with no component errors

A failed Metadata API deployment often reports no component errors because the cause sits in another part of the result. The post explains the result layout, using Salesforce’s documentation. The overall outcome is in the DeployResult returned by checkDeployStatus(), but the detail is in its details field, which is only populated when includeDetails is set to true.

The details hold componentFailures and componentSuccesses, each a list of DeployMessage entries, plus runTestResult and retrieveResult where applicable. Each DeployMessage is typed as Warning or Error, a distinction that did not exist before API version 18.0, when every problem stopped the deployment. While a deployment is running, only componentFailures is filled in; the other fields appear after it finishes, so a mid-run check can show failures with no test results yet.

Test-side problems sit one level further down, in runTestResult. Failing tests are listed in its failures, and coverage problems in codeCoverageWarnings. A deployment can therefore fail with componentFailures empty and no test failing, for example when a class is not covered under a RunSpecifiedTests run. The post closes with a checklist: confirm includeDetails was set, check componentFailures, then check runTestResult failures and coverage warnings, make sure the deployment has finished, and compare the package’s classes with the classes the named tests cover.

The post also notes that the component lists moved from the deployment result into details, a change Salesforce says took effect in API version 29.0, so older scripts may look in the wrong place.

Read the original at dev.to (opens in a new tab)

Worth reading?

Must-read

When Salesforce runs Apex tests on a deployment, and how to run fewer (opens in a new tab)

You will learn which test levels Salesforce applies by default, the coverage rules that constrain RunSpecifiedTests, and five practical ways to shorten production deployments.

Why read this

The post also flags that one Flow-related default is not yet verified in production.

  1. Check whether the package contains Apex or Flows
  2. Pick a test level or accept the default
  3. Apply the 75% coverage rule
  4. Quick deploy a validated package
How Salesforce decides which Apex tests to run on a production deployment

Apex tests are usually the slowest part of a Salesforce deployment to production. The article lists the test levels the Salesforce CLI offers: NoTestRun, RunSpecifiedTests, RunLocalTests, RunAllTestsInOrg and RunRelevantTests, the last still in beta. When no level is chosen, the default depends on the target: sandboxes and Developer Edition orgs run no tests, while production runs all local tests if the package contains Apex classes or triggers. The author notes that Flows set to activate on deployment also count, which is a common cause of unexpectedly slow deployments.

The coverage rules decide whether a production deployment can pass. With RunLocalTests or RunAllTestsInOrg, the org needs at least 75% Apex coverage overall and every test that runs must pass. With RunSpecifiedTests, each Apex class and trigger in the package needs 75% coverage on its own from the named tests, so a class with no selected test fails even when a full run would have passed.

The article gives five ways to run fewer tests: keep unchanged Apex out of the package, deploy only the differences from the target, specify tests while checking per-class coverage, consider RunRelevantTests with its beta limits in mind, and validate ahead then quick deploy within 10 days. It also suggests shipping configuration separately from code, since a package with no Apex needs no tests at the default level. The author tested check-only deployments against a Developer Edition org only, so the Flow default has not been confirmed in production. The post closes by describing how the Diffbridge tool’s Smart test level automates these choices.

Read the original at dev.to (opens in a new tab)

Worth reading?

Recommended

Why RunSpecifiedTests fails on a class RunLocalTests passes (opens in a new tab)

You will learn how RunLocalTests and RunSpecifiedTests apply different per-class coverage rules, why a specified run can fail at 0% coverage, and where the coverage warning appears in Metadata API results.

RunLocalTests

  • Runs all local tests
  • Overall coverage of at least 75%
  • Coverage counted from all tests that ran

RunSpecifiedTests

  • Runs only the named tests
  • Each class at least 75% individually
  • Coverage counted from named tests only
RunLocalTests and RunSpecifiedTests apply different coverage rules

Salesforce production deployments are usually validated at one of two test levels, RunLocalTests and RunSpecifiedTests. RunLocalTests runs every test in the org except those from installed managed and unlocked packages, and it is the default when the package contains Apex classes or triggers. RunSpecifiedTests runs only the tests named in the runTests option.

The two levels count coverage differently. RunLocalTests requires overall org coverage of at least 75 percent, so a weak class can pass if the rest of the org is well covered. RunSpecifiedTests requires each Apex class and trigger in the package to reach 75 percent individually, and only the named tests count toward that figure. A class covered by none of the named tests therefore fails the deployment even when a full local run would have passed.

The article gives a hypothetical package of 13 components with three Apex classes, where two named tests cover two of them and the third sits at 0 percent. Two fixes are offered: add a test that covers the class, or remove the class from the package if it has not changed. Coverage failures are reported under details.runTestResult.codeCoverageWarnings in the checkDeployStatus() result, which appears only when includeDetails is true, so tooling that prints just the error lists can make such a failure look unexplained.

The author suggests RunLocalTests when the simplest and safest run matters more than time, or when it is unclear which tests cover which classes. RunSpecifiedTests suits teams that know the covering tests for every class and want a shorter run. The piece also notes that RunRelevantTests is in beta and should be checked against current documentation, and that NoTestRun applies only to development environments, not production. The Salesforce CLI exposes these choices through –test-level and –tests. The article closes with a note on the author’s own tool, Diffbridge.

Read the original at dev.to (opens in a new tab)

Worth reading?

Validate ahead of the release window, then quick deploy without re-running tests (opens in a new tab)

You will learn what conditions a validation must meet to be promoted by quick deploy, including the 10-day limit and coverage rules, and how to structure a release around it.

Why read this

You will also see a CLI caveat about validating packages with no tests.

  1. Validate ahead of the window against the target
  2. Check the validation passed and note its ID
  3. Quick deploy that ID inside the window
  4. Validate again if the package or target changes
The validate-then-quick-deploy workflow for a release window

Production deployments that run Apex tests are slow, and the release window is short. Salesforce lets you run a deployment as a validation, also called a check-only deployment, which runs everything a real deployment would, tests included, but saves nothing in the org. If the validation passes, you can later promote it with a quick deploy, which deploys the validated components without running the Apex tests again. The Metadata API calls this deployRecentValidation(), the Salesforce UI offers it on the Deployment Status page, and the CLI uses sf project deploy validate followed by sf project deploy quick.

Salesforce sets several conditions. The components must have validated successfully for the target environment within the last 10 days, and the Apex tests in the target org must have passed as part of that validation. Code coverage must also be met: with all tests or all local tests, overall coverage must be at least 75% and Apex triggers must have some coverage; with RunSpecifiedTests, each deployed class and trigger must be at least 75% covered individually. Salesforce says a validation with passing tests only sometimes qualifies, so the author advises confirming it rather than assuming. Trailhead’s guidance adds that you should not deploy again or make major changes to the org in between.

Two consequences follow. A validation without tests cannot be promoted this way, because the quick deploy skips tests that the validation already ran, so there is nothing to skip. The tests chosen at validation time are the tests you get, and a quick deploy does not add or change them. If the per-class coverage rule fails under RunSpecifiedTests, the quick deploy is unavailable, so it is better to discover that during validation than inside the window. The suggested workflow is to validate ahead of the window against the same target with the test level you will rely on, check that it passed, note its ID, then quick deploy that ID inside the window. If the package or target changes, validate again. The 10-day limit is the main thing to watch, since a validation run before a long weekend may have expired.

The author also reports that sf project deploy validate rejected –test-level NoTestRun in their CLI run. To check a package with no tests, sf project deploy start –dry-run –test-level NoTestRun performs a check-only deployment, but nothing can be quick deployed afterwards. Some Stack Exchange answers report that a CLI –dry-run is not treated as a validation by sf project deploy quick, so use sf project deploy validate when planning a quick deploy and check this against your CLI version.

Read the original at dev.to (opens in a new tab)

Worth reading?

Must-read

Building Custom Objects and Permission Sets with the Salesforce Development Plugin for Claude Code (opens in a new tab)

You will learn how to set up the Salesforce Development Plugin in Claude Code, prepare an org with the metadata-experts and salesforce-api-context MCP Servers, and generate a Custom Object, Permission Sets and a Lightning page as metadata.

Why read this

You will also see why the older Salesforce DX MCP Server is being retired and why deployments should stay with humans.

  1. Create the DX project
  2. Build the Custom Object and fields
  3. Build the Permission Sets
  4. Build the Lightning page
  5. Package the metadata for a human to deploy
The main stages of building metadata with the plugin in the worked example

The article explains how the Salesforce Development Plugin for Claude Code differs from other tools with similar names. It groups Skills, the Salesforce CLI and hosted metadata servers into one toolset, while the Salesforce DX MCP Server reaches end-of-life on November 2, 2026, and Salesforce in Claude is aimed at end users rather than builders. The author lists the prerequisites: Node.js, Python, the Salesforce CLI and Claude Code, with a Claude plan that includes Claude Code. The org must have the MCP Servers page under Integrations and API Catalog used to enable the metadata-experts and salesforce-api-context MCP Servers.

The walkthrough then installs the plugin with the claude plugin install command and runs the setup command to check the org connection. The author builds a worked example, The General Store, using prompts that create a DX project, an Equipment Loan Custom Object with picklists, a lookup and a long text field, two Permission Sets, and a Lightning Record Page. He reviews the generated XML to confirm the read, create and edit permissions match the requirements.

The piece closes with advice on safety. It recommends building in a sandbox, Developer Edition org or Scratch Org, keeping deployments in human hands, and giving the agent specific field names and permissions because the model is trained on generic data.

Read the original at Salesforce Ben (opens in a new tab)

Worth reading?

Must-read

Agentforce agents move to AiAgentDefinition metadata types in API version 68.0 (opens in a new tab)

You will learn how the new AiAgentDefinition and AiAgentDefinitionVersion types replace Bot, GenAiPlannerBundle and AiAuthoringBundle for Agentforce agents, how to write a manifest and retrieve a single version with its dependencies, and which deployment rules and migration steps apply.

Agentforce agent at API 68.0

  • AiAgentDefinition
  • AiAgentDefinitionVersion
  • AiAuthoringBundle
The three old metadata types and the two new types that replace them

Winter ’27 introduces two metadata types for Agentforce agents at API version 68.0: AiAgentDefinition, which holds agent-level settings, and AiAgentDefinitionVersion, which holds one version’s settings, messages and an inline planner with its subagents and actions. Under the previous structure, one agent was spread across the Bot, GenAiPlannerBundle and AiAuthoringBundle types, with generated name suffixes, hard-to-find welcome messages and folder names that changed between retrieves. The author compares a sample agent retrieved at API 67.0 and 68.0, showing that the content was identical and only the names and packaging changed.

At API 68.0, Agentforce agents must use the new types, and retrieving or deploying them as Bot or BotVersion returns an error. The # delimiter lets a manifest or the –metadata flag select a single version, such as TestAgent#1, all versions with TestAgent#, or every version of every agent. Salesforce CLI version 2.149.9 or later is needed, and the –root-type-with-dependencies AiAgentDefinitionVersion flag pulls in the parent definition, the authoring bundle and the Flows, Apex classes and Prompt Templates the version uses. The dependency retrieve is limited to 25 requests per day, 100 components per request, and one level deep.

Deployments fail if the old and new formats are mixed, if a version is deployed without its definition existing in the target org or the same deployment, or if the Agent Script source is omitted. The author also notes that the agent user from the source org must be replaced for a draft agent, and recommends switching to API 68.0 in its own commit and updating any scripts that parse the old files.

Read the original at Salesforce Developers Blog (opens in a new tab)

Worth reading?

Must-read

Custom sharing reasons now roll out for standard objects alongside a setting to preserve manual shares (opens in a new tab)

You will learn how to use the new custom sharing reason feature on standard objects and configure the org-wide setting that keeps manual shares intact during record transfers.

Why read this

The article provides exact metadata and Apex examples so you can implement these changes immediately.

Keep Manual Shares

  • Available immediately in Sharing Settings
  • Keeps user manual shares after ownership changes
  • Best for teams relying on manual distribution

Custom Row Causes

  • Rolls out via Metadata API through October
  • Defines programmatic sharing reasons in code
  • Best for developers using Apex or Flow
Two new Salesforce sharing features help records keep access after owner changes

Salesforce is introducing two enhancements to the sharing model that eliminate long-standing workarounds for standard object access control. The first is an org-wide toggle called Keep Manual Shares when Transferring Records, which is available immediately in Sharing Settings. Enabling it ensures that manual shares survive ownership changes without requiring custom code or triggers.

The second enhancement rolls out through October and allows developers to define custom row causes on standard objects using the Metadata API. Previously, Apex managed sharing was restricted to Custom Objects. The update lets you declare a sharing reason like On Call Expert directly in the CustomObject metadata, then reference it in Apex share records or Flow actions. This separation keeps programmatic shares distinct from user manual shares and prevents automatic deletion when owners change.

The guidance recommends evaluating existing code that creates CaseShare, AccountShare, or similar records. Teams building shares via Apex or Flow should migrate to custom row causes to maintain auditability and stability. Those relying purely on manual distribution can simply enable the preservation setting. Both features arrive ahead of November updates that will bring management capabilities to Agentforce and Setup.

Read the original at Salesforce Developers Blog (opens in a new tab)

Worth reading?