{"id":6233,"date":"2021-07-21T07:39:07","date_gmt":"2021-07-21T07:39:07","guid":{"rendered":"https:\/\/www.greytrix.com\/blogs\/salesforce\/?p=6233"},"modified":"2021-07-21T07:39:09","modified_gmt":"2021-07-21T07:39:09","slug":"how-to-remove-apex-code-from-production-environment","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/07\/21\/how-to-remove-apex-code-from-production-environment\/","title":{"rendered":"How to remove Apex Code from Production Environment"},"content":{"rendered":"\n<p>It is fairly effortless to delete an unwanted apex class or trigger in a Sandbox Environment. On the other hand, Unlike the Sandbox environment, it is not possible to delete code from Production environment just by clicking in the DELETE Button. Here are some methods that may work for you. NOTE: Please consider that deleting or removing code from Production affects the code coverage of the Org. Ensure that the coverage is above 75% which is the salesforce standard.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong><em><span style=\"text-decoration: underline;\">Comment the Code<\/span><\/em><\/strong><\/h4>\n\n\n\n<p>The easiest way would be to comment the code. This method obviously doesn\u2019t delete the apex class but it is a relatively quick fix. The code is commented in the Sandbox Environment and deployed to Production.<\/p>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2021\/07\/1_CommentClass.jpg\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" class=\"size-full\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px; align: center;\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2021\/07\/1_CommentClass.jpg\" alt=\"Comment Class\"><\/a><\/center>\n<font size=\"2\"><center><i>Comment Class<\/i><\/center><\/font>\n\n\n\n<h4 class=\"wp-block-heading\"><strong><em><span style=\"text-decoration: underline;\">Using Workbench<\/span><\/em><\/strong><\/h4>\n\n\n\n<p>We are going to delete MyRestResource.apxc<\/p>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2021\/07\/2_AllClasses.jpg\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" class=\"size-full\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px; align: center;\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2021\/07\/2_AllClasses.jpg\" alt=\"All Classes\"><\/a><\/center>\n<font size=\"2\"><center><i>All Classes<\/i><\/center><\/font>\n\n\n\n<ul class=\"wp-block-list\" type=\"a\"><li>Create an xml file and save it as package.xml.<\/li><li>Enter the following snippet into the xml file and save it. (If required update the version to the latest one).<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?&gt;\n&lt;Package xmlns=\"http:\/\/soap.sforce.com\/2006\/04\/metadata\"&gt;\n&lt;version&gt;51.0&lt;\/version&gt;\n&lt;\/Package&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>Create another file, copy the below text and save it as \u201cDestructiveClasses.xml\u201d. to delete multiple files, add more &lt;members&gt; nodes and update the class name into the nodes. To delete triggers, add a &lt;types&gt; node and enter &lt;name&gt; as ApexTrigger.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?&gt;\n&lt;Package xmlns=\"http:\/\/soap.sforce.com\/2006\/04\/metadata\"&gt;\n&lt;version&gt;51.0&lt;\/version&gt;\n&lt;types&gt;        \n&lt;members&gt; MyRestResource &lt;\/members&gt;        \n&lt;name&gt;ApexClass&lt;\/name&gt;\n&lt;\/types&gt;\n&lt;\/Package&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\" type=\"a\"><li>Save the two files and zip them together. Name the zip file as package.zip.<\/li><li>Login to Workbench and select Migration and go to Deploy, upload the zip file and enable &#8216;Rollback On Error&#8217;, &#8216;Single Package&#8217; and \u2018Check Only\u2019. Click next and deploy.<\/li><\/ul>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2021\/07\/3_workbenchSetup.jpg\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" class=\"size-full\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px; align: center;\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2021\/07\/3_workbenchSetup.jpg\" alt=\"Workbench Setup\"><\/a><\/center>\n<font size=\"2\"><center><i>Workbench Setup<\/i><\/center><\/font>\n\n\n\n<ul class=\"wp-block-list\"><li>If the validation is Success, Uncheck the \u201cCheck only\u201d checkbox and continue the deployment.<\/li><\/ul>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2021\/07\/4_successMessage.jpg\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" class=\"size-full\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px; align: center;\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2021\/07\/4_successMessage.jpg\" alt=\"Success Message\"><\/a><\/center>\n<font size=\"2\"><center><i>Success Message<\/i><\/center><\/font>\n\n\n\n<ul class=\"wp-block-list\"><li>Once you receive the success message, the class will be deleted.<\/li><\/ul>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2021\/07\/5_ClassDeleted.jpg\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" class=\"size-full\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px; align: center;\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2021\/07\/5_ClassDeleted.jpg\" alt=\"Class Deleted\"><\/a><\/center>\n<font size=\"2\"><center><i>Class Deleted<\/i><\/center><\/font>\n\n\n\n<p>Using the steps mentioned in the blog above, we hope you are able to extract the code from Production org of your Salesforce.<\/p>\n\n\n\n<p>We hope you may find this blog resourceful and helpful. If you still have concerns and need more help, please contact us at <a href=\"mailto:salesforce@greytrix.com\">salesforce@greytrix.com<\/a>.<\/p>\n\n\n\n<p style=\"text-align: justify\"><b>About Us<\/b><\/br>\n<p><a href=\"https:\/\/www.greytrix.com\/\">Greytrix<\/a> \u2013 a globally recognized and one of the oldest Sage Development Partner and a Salesforce Product development partner offers a wide variety of integration products and services to the end users as well as to the Partners and Sage PSG across the globe. We offer Consultation, Configuration, Training and support services in out-of-the-box functionality as well as customizations to incorporate custom business rules and functionalities that require apex code incorporation into the Salesforce platform.<br><br> Greytrix has some unique solutions for Cloud CRM such as <a href=\"\">Salesforce Sage integration<\/a> for <a href=\"https:\/\/www.greytrix.com\/sage-x3-erp\/integration\/\">Sage X3<\/a>, <a href=\"https:\/\/www.greytrix.com\/salesforce-cloud-services\/sage-100-integration\/\">Sage 100<\/a> and <a href=\"https:\/\/www.greytrix.com\/salesforce-cloud-services\/sage-300-integration\/\">Sage 300 (Sage Accpac)<\/a>. We also offer best-in-class Cloud CRM <a href=\"https:\/\/www.greytrix.com\/salesforce-cloud-services\/crm-development\/\">Salesforce customization and development services<\/a> along with services such as Salesforce <a href=\"https:\/\/www.greytrix.com\/salesforce-cloud-services\/data-migration-support\/\">Data Migration<\/a>, <a href=\"https:\/\/www.greytrix.com\/salesforce-cloud-services\/crm-development\/\">Integrated App development<\/a>, Custom App development and Technical Support business partners and end users. Salesforce Cloud CRM integration offered by Greytrix works with Lightning web components and supports standard opportunity workflow. Greytrix GUMU&#x2122; integration for Sage ERP \u2013 Salesforce is a 5-star rated app listed on <a href=\"https:\/\/appexchange.salesforce.com\/appxListingDetail?listingId=a0N30000000psM5EAI\" target=\"_blank\" rel=\"noopener\">Salesforce AppExchange<\/a>.<br> The GUMU&#x2122; Cloud framework by Greytrix forms the backbone of cloud integrations that are managed in real-time for processing and execution of application programs at the click of a button.<br><br> For more information on our Salesforce products and services, contact us at <a href=\"mailto:salesforce@greytrix.com\">salesforce@greytrix.com<\/a>. We will be glad to assist you.<\/p>\n\n\n\n<p><strong>Related Posts<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\" id=\"block-95f1dc03-6e6e-4324-a224-6cb667f07601\"><li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/06\/28\/how-to-display-toasts-or-notices-using-lightning-notificationlibrary\/\" data-type=\"URL\" data-id=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/06\/28\/how-to-display-toasts-or-notices-using-lightning-notificationlibrary\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Display Toasts or Notices using Lightning : NotificationLibrary<\/a><\/li><li><a rel=\"noreferrer noopener\" href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/06\/15\/how-to-add-or-remove-css-style-from-the-component-element-during-runtime-or-dynamically\/\" target=\"_blank\">How to Add or Remove CSS style from the component\/element during runtime or dynamically<\/a><\/li><li><a rel=\"noreferrer noopener\" href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/05\/29\/how-to-add-utility-bar-in-a-salesforce-lightning-application\/\" target=\"_blank\">Adding Utility bar in a Salesforce lightning application<\/a><\/li><li><a rel=\"noreferrer noopener\" href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/04\/12\/how-to-notify-user-about-unsaved-changes-on-the-ui-using-lightning-component\/\" target=\"_blank\">How to Notify User about Unsaved Changes on the UI using Lightning Component<\/a><\/li><li><a rel=\"noreferrer noopener\" href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/03\/24\/add-delete-row-dynamically-in-salesforce-lightning\/\" target=\"_blank\">Add Delete Row Dynamically In Salesforce Lightning<\/a><\/li><li><a rel=\"noreferrer noopener\" href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/01\/22\/salesforce-how-to-get-row-index-of-lightning-table-rows\/\" target=\"_blank\">Salesforce \u2013 How to get row index of lightning table rows<\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>It is fairly effortless to delete an unwanted apex class or trigger in a Sandbox Environment. On the other hand, Unlike the Sandbox environment, it is not possible to delete code from Production environment just by clicking in the DELETE Button. Here are some methods that may work for you. NOTE: Please consider that deleting\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/07\/21\/how-to-remove-apex-code-from-production-environment\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[88,1175,1173,1174,206,1055,1069,1133,207,208,1154,367,651],"class_list":["post-6233","post","type-post","status-publish","format-standard","hentry","category-salesforce-srv","tag-delete","tag-delete-class","tag-delete-class-from-production","tag-delete-class-from-salesforce-production","tag-lightning","tag-lightning-aura-component","tag-lightning-aura-method","tag-lightning-basic","tag-lightning-basics","tag-lightning-component","tag-remove-class","tag-salesforce","tag-salesforce-lightning-component"],"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/6233","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/comments?post=6233"}],"version-history":[{"count":2,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/6233\/revisions"}],"predecessor-version":[{"id":6243,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/6233\/revisions\/6243"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/media?parent=6233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/categories?post=6233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/tags?post=6233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}