Please choose a different name
Detection
- RegExp:
Error (.*) This (.*) already exists or has been previously used(.*)Please choose a different name.
Examples
Error Invoice__c This Invoice already exists or has been previously used. Please choose a different name.
Resolution
An item named {1} exists, or existed, in the target org: deleted items keep their name for 15 days.
- If a deleted field holds the name, erase it in the target org: Setup -> Object Manager -> the object -> Deleted Fields -> Erase
- Or rename the existing {1} in the target org, deploy, then delete the renamed item
- The manual deployment action below reminds to do it in each org of the pipeline, with a checkbox in the Pull Request comments
Deployment action
A deployment action can solve this error. Create it on the Pull Request of the current branch:
sf hardis:project:action:create --agent --scope pr --pr-id current --when pre-deploy --type manual --label "Free the name {1}" --instructions "1. In Setup, open Object Manager, the object of {1}, then Deleted Fields (or the list of deleted items of its type)
2. Erase the deleted item named {1}, or rename the existing one
3. If no item uses the name {1} anymore, there is nothing to do"
Documentation: https://sfdx-hardis.cloudity.com/salesforce-devops-work-on-user-story-deployment-actions-manual/