Delete Metadata Scenarios

Updated 2 months ago by Copado Solutions

The Destructive Changes operation allows you to delete a component in Git as well as in the destination environment.

If you use this option on a user story, the component will be deleted both from Git and from the user story. However, if you just want to delete the component in Git, you can use this option on a Git snapshot.

There are different scenarios where you may want to use this operation. Here, we will describe some of them in more detail.

The Wrong Metadata Has Been Deployed to Production

  1. Delete the item in your lowest development org:
    1. Change other metadata if required.
  2. Create a clean-up user story linked to your dev org. Follow a naming convention for the title of the user story in order to be able to find user stories more easily. E.g. 'Delete: Remove Custom Sales Layout'.
  3. Click on Commit Changes and select Destructive Changes as Git Operation type.
  4. As you have already deleted the element in your current org, select the org credential of one of the next environments in your pipeline. This will change the metadata grid so that you can select the deleted item, however the commit will be against your dev org.
  5. Commit the item you would like to delete. Provide a meaningful commit message.
  6. If you have to commit other changes, click again on Commit Changes and commit the modified items.
  7. Promote the user story to production.

The Wrong Metadata Has Been Deployed to QA/UAT

The Item You Need to Delete Is Not Part of a Current User Story Selection
  1. Delete the item in your lowest development org:
    1. Change other metadata if required.
  2. Create a clean-up user story linked to your dev org. Follow a naming convention for the title of the user story in order to be able to find user stories more easily.e.g. 'Delete: Remove Custom Sales Layout'.
  3. Click on Commit Changes and select Destructive Changes as Git Operation type.
  4. As you already have deleted the element in your current org, select the org credential of one of the next environments in your pipeline. This will change the metadata grid so that you can select the deleted item, however the commit will be against your dev org.
  5. Go to the Advanced section.
  6. Select QA/UAT as new base branch.
  7. Commit the item you would like to delete. Provide a meaningful commit message.
  8. If you have to modify other items, click again on Commit Changes and commit the modified items.
  9. Promote the user story to the environment and do not move it any further.
The Item You Need to Delete Is Part of a Current User Story Selection
  1. Delete the item in your lowest development org:
    1. Change other metadata if required.
  2. Move your original user story back to the environment where you made the deletion and changed your metadata to delete it properly.
  3. In the original user story, go to Commit Changes and select Recommit Files as Git Operation type. Also, check the Recreate Feature Branch checkbox.
  4. In the selection, remove the item(s) you deleted and finish the commit.
  5. Create a clean-up user story linked to your dev org. Follow a naming convention for the title of the user story in order to be able to find user stories more easily.e.g. Delete: Remove Custom Sales Layout.
  6. Click on Commit Changes and select Destructive Changes as Git Operation type.
  7. As you have already deleted the element in your current org, select the org credential of one of the next environments in your pipeline. This will change the metadata grid so that you can select the deleted item, however the commit will be against your dev org.
  8. Go to the Advanced section.
  9. Select QA/UAT as new base branch.
  10. Commit the item you would like to delete. Provide a meaningful commit message.
  11. Check your commits to make sure that what was committed is what you expected.
  12. Check the Ready to Promote checkbox in both user stories.
  13. Go to the Pipeline page, select the forward arrow in the environment both user stories are currently in.
  14. Go to the User Stories Ahead tab on the modal, select your user stories and choose one of the options below:
    1. Click on Promote and Deploy if you want to deploy both user stories without further intervention.
    2. Click on Promote if you want to review the promotion branch, add more user stories to the promotion or if you need to make any further modifications prior to the deployment.
The Item Was Deleted in All Salesforce Orgs but It Still Shows in Git
  1. Go to the Git Snapshot record of the main org (production snapshot).
  2. Click on Commit Changes and select Destructive Changes to delete the component in Git.
  3. All the new feature branches created out of the main branch (aka master) will no longer include the item.


How did we do?