Error overview
You may run into this Salesforce validation error when deploying a deletion of a Profile from the target org.
In Gearset the error message would be reported as below:
"This profile is referenced elsewhere in Salesforce. Remove the usage and try again. <xxx>
"
"<xxx>
" in this context refers to a specific metadata item (and its ID) that references the Profile you're attempting to delete.
Explanation of the error
The validation fails because the Profile referenced in the error message is associated with another item in the target org (in this case with Login Flow
).
Resolution
The root cause of the issue may vary depending on whether you're attempting to deploy the Profile to the target org or remove it from the target org.
If you're trying to deploy Profile to the target org
The error may surface because one of the following reasons:
Login Flow
where the Profile is referenced doesn't exist in the target org. In which cause you may need to deploy it first, and then follow up with Profile deployment.Login Flow
is missing is the deployment package, and would need to be included along with the Profile.
If you're deleting the Profile from the target org
Workaround 1
If you're deploying a deletion of the Profile, you'd need to first manually delete from the target org the metadata item that references the Profile.
On the above example, it is theLogin Flow
that'd need to be deleted from the target org.
Workaround 2 (applies for CI job deployments)
If you're attempting to deploy a deletion of the profile via a PR (pull request) in your Gearset Pipeline, as a workaround you can exclude the deployment of deleted items from the CI job.
βNote: This will not delete the Profile from the target org, but should help with the validation of the PR.
βOn CI dashboard click on the CI job, select
Edit settings
, navigate toDeployment behavior
, untick "Deleted items
" option and save the changes.Once done, you can re-validate the PR against the target environment.
β
Disclaimer: This error is returned by Salesforce directly, 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.