Error overview
Salesforce returns this error on a Custom field when it can't get exclusive access to what it needs to change in the target org, because another operation in that org is holding it. The Custom field fails validation, and so does every component in the package that references that field.
Explanation of the error
You may run into this Salesforce validation error when deploying Custom fields with Compare and deploy, or when a pull request (PR) is validated in Gearset Pipelines.
An example of this error in Gearset, where <xxx> is a reference to a line number in the XML file:
unable to obtain exclusive access to this record (line:<xxx>)
This error comes from the Salesforce Metadata API, not from Gearset. In cases reported to us, users got the same error when they deployed the same Custom fields with Workbench and with a Salesforce change set.
When do we see this error on Custom fields?
In the cases reported to us, the error on Custom fields had these things in common:
The Custom fields were new, so they didn't exist in the target org yet. Several were formula fields.
The deployment often included several new Custom fields on the same object, for example the Account, Case, Work Order, or Opportunity object.
The same changes were deployed successfully to earlier environments, and failed only in one org, such as a UAT Sandbox, a Full Sandbox, or Production.
The error kept coming back on every validation, in some cases for a prolonged period of time.
Why do other components fail with "no CustomField named" errors?
When a Custom field fails with this error, Salesforce doesn't create it in the target org. Every other component in the package that references that Custom field is likely to fail as well - this is because Salesforce can't find the field.
In the cases reported to us, these errors appeared alongside the record lock error:
Layout, Profile, and Permission set:
In field: field - no <CustomField> named <Object.Field__c> foundApex class:
Variable does not exist: <Field__c>Flow and Field set: validation errors saying that the new Custom field can't be found.
Resolve the record lock error on the Custom field first. In cases reported to us, the errors on the other components cleared once the Custom field existed in the target org.
Splitting the Custom field and trying to deploy it separately, or via a separate PR in Gearset Pipelines, doesn't fix the record lock error on its own.
Users who deployed only the Custom fields still got the error until they used one of the workarounds below.
Resolution
The guidance below helps you deploy Custom fields that fail with this error. Each workaround listed in this article fixed the error for at least one user who reported it to us. Try them in this order, and re-validate after each one.
The following table shows what resolved the error in the cases reported to us.
Workaround | What happened |
Re-run the validation later | The error cleared after waiting and re-running the validation. Note that in some cases re-validation worked only after 2 or 3 attempts. |
Erase deleted Custom fields in the target org | The target org had more than 700 deleted Custom fields waiting to be erased. The deployment succeeded once they were erased. |
Deploy fewer Custom fields at a time | The fields deployed successfully in smaller groups, in one case 4 fields per deployment. |
Create the Custom field manually in the target org | The field could be created in Setup, and the rest of the package then validated successfully. |
Workaround 1: Re-run the validation after waiting
Some record locks clear on their own, once the operation holding them finishes in the target org.
Check that nothing else is deploying to, or running in, the target org. In one case reported to us, a process running in the target Sandbox was the cause.
Wait, then re-run the validation in Gearset.
If the error comes back after 2 or 3 attempts, move on to Workaround 2.
Workaround 2: Erase deleted Custom fields on the object in the target org
Salesforce keeps a deleted Custom field for 15 days, unless you erase it. In one case reported to us, the target org had more than 700 deleted Custom fields waiting to be erased. Once they were erased, the new Custom fields deployed without the error.
In the target org, go to Setup > Object Manager and open the object named in the error, for example Account.
Select Fields & Relationships, then Deleted Fields.
For each field you no longer need, select Erase. Erasing a field deletes it and its data permanently, so check with your team first whether this is safe to execute.
Re-run the validation in Gearset.
For more on the Deleted Fields page, see Salesforce Ben's guide How to Restore Deleted Salesforce Fields (updated March 2025).
Workaround 3: Deploy fewer Custom fields at a time
In cases reported to us, a package with many new Custom fields on the same object failed, while smaller groups of the same fields deployed successfully. In one case, 10 fields validated and 11 didn't. In another, the user deployed the fields in 6 separate deployments of about 4 fields each.
For deployments made via Compare and deploy
In your comparison, select only a few of the new Custom fields.
Validate and deploy them.
Repeat the steps for the remaining Custom fields, then deploy the components that reference them, such as Layouts, Profiles, and Apex classes.
For more on breaking up a deployment, see Splitting a complex deployment into stages.
For a PR failing validation in Gearset Pipelines
Create a new feature branch and PR that contain only a few of the new Custom fields.
Promote the new PR to the environment, and let the CI job deploy it to the org.
Repeat these steps for the remaining Custom fields.
Once all the Custom fields are deployed to the target org, re-validate the original PR that failed with error
unable to obtain exclusive access to this record.
Workaround 4: Create the Custom field manually in the target org
In cases reported to us, users could create the failing Custom field in Setup, even though Salesforce reported a failed attempt to create the same field via Metadata API deployment.
Once the Custom field existed in the target org, the rest of the package validated.
In the target org, create the Custom field in Setup with the same API name, type, and settings as in your source environment.
Re-run the validation in Gearset.
In one case, Salesforce only let the user create the field after they cleared the Add this field to existing custom report types that contain this entity checkbox.
What if none of the workarounds fix the error?
If the Custom field still fails with unable to obtain exclusive access to this record, the lock is held by something in the target org that only Salesforce can see.
Confirm whether the error occurs when attempting the deployment outside Gearset. You can do it by deploying the same Custom field with Workbench or the Salesforce CLI.
Open a case with Salesforce support, with the object name, the Custom field names, and the time of the failed validation. In one case reported to us, Salesforce support had to clean up something in the org before the fields could be deployed.
Is this the same as the UNABLE_TO_LOCK_ROW error in data deployments or unit tests?
The wording of the error message returned is the same, but the cause and the fix are different.
This article covers Custom fields failing validation in a Metadata API deployment via Compare and deploy, or a PR validation in Gearset Pipelines. It doesn't cover the same error on records in data deployments (e.g. via Gearset's Sandbox Seeding tool), or in Apex tests run by Unit test jobs.
For the other two cases, see our guidance on:
Apex tests in Unit test jobs: Troubleshooting error "UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record" in Unit test jobs
Disclaimer: This error is returned directly by Salesforce, rather than Gearset. Even so, we offer guidance based on our combined experience with the Metadata API. Where possible, we try to help guide you to fix or avoid this error. In the case that this isn't possible, we may need to direct you to Salesforce support for further clarification.


