Sunday 19 April 2015

Deleting Metadata Components - Destructive Changes

Hi Everyone,

As everyone knows that destructivechange.xml is the way to delete the metadata components in salesforce.

Recently came across this scenario, I need to delete a field in a custom field in salesforce which is also referred in the apex class. In this case, we will modify the apex class so that it isn't reflected in the deletion of the custom field.

During Deployment Process, we will be updating the apex class as single round of deployment and then adding the custom field to be deleted in the next round of deployment.

Instead of doing that in 2 different goes, we can make use of the following stuff which is available from version33.0

#1.DestructiveChangesPre.Xml
#2.DestructiveChangesPost.Xml

We just need to add the customfield to DestructiveChangesPost.Xml and add the modifed apex class to the package.xml files and hold the 2 files in the directory to be deployed and run the target .

Likewise, if you have scenario to delete metadata components before updating any specific metadata components you can make use of the DestructiveChangesPre.Xml file.

Leave your comments here, so that it would be helpful for me to continuing writing this sort of technical articles.

Happy Coding

Thanks
Mariappan Perumal
+91-95979-21112