<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Matheus Gonçalves on Medium]]></title>
        <description><![CDATA[Stories by Matheus Gonçalves on Medium]]></description>
        <link>https://medium.com/@matheusdev?source=rss-fbf3d2870161------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*k3KiLN97-TZgYBqaZeS6Zg.png</url>
            <title>Stories by Matheus Gonçalves on Medium</title>
            <link>https://medium.com/@matheusdev?source=rss-fbf3d2870161------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 15 Nov 2026 06:32:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@matheusdev/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to mock formulas and read-only relationships in Apex tests?]]></title>
            <link>https://matheusdev.medium.com/how-to-mock-formulas-and-non-writable-relationships-in-apex-2aca1595aab4?source=rss-fbf3d2870161------2</link>
            <guid isPermaLink="false">https://medium.com/p/2aca1595aab4</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[salesforce-development]]></category>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[apex]]></category>
            <category><![CDATA[mock]]></category>
            <dc:creator><![CDATA[Matheus Gonçalves]]></dc:creator>
            <pubDate>Fri, 25 Mar 2022 01:36:52 GMT</pubDate>
            <atom:updated>2022-03-25T22:02:15.408Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Post header. Mockup of a laptop showing an interface of Salesforce, with the blue cloud, and Matheus Gonçalves logo. On the left of the laptop there are some colorful blocks and dots floating towards the screen." src="https://cdn-images-1.medium.com/max/1024/1*WCUtZI6wammO8qZKjdNIag.jpeg" /></figure><p><em>Learn how to use dependency injection to mock read-only fields, such as formula fields and child relationships in your tests.</em></p><p>⚙️ Repository on Github: <a href="https://github.com/gitmatheus/MockFieldReader">Mock Field Reader</a>.</p><p>A while ago we explored the <a href="https://github.com/gitmatheus/Mock-Data-Layer-Pattern">Mock Data Layer Pattern</a>, which allows us to mock virtually any relationships between records within your tests. This is especially handy when trying to improve the performance of these tests — more details <a href="https://matheusdev.medium.com/unit-test-can-we-mock-relationships-in-apex-b69bc9f8601f">here</a>.</p><p>Now, <strong>how can we mock formula fields and</strong> <strong>read-only</strong> <strong>child relationships</strong> if they are, well, read-only fields? 🤔</p><h3>Mocking values in read-only fields</h3><p>For this exploratory project, we will continue using the convenience of <strong>interfaces and dependency injection</strong>, but this time to develop a class used to mock field values.</p><p>We will use a <em>not-so-realistic</em> scenario with parent and child accounts, but the intent is to create a test for the <strong>Account Trigger Handler</strong> that will use a <strong>Mock Field Reader</strong> and a <strong>Mock Data Layer</strong>.</p><p>The <strong>Mock Field Reader</strong> will be used so we can mock two <strong>read-only</strong> fields on the Account object.</p><ul><li>Child_Accounts__r, <strong>a read-only child relationship</strong> on the parent record.</li><li>External_URL__c, a <strong>formula field</strong> on the child record.</li></ul><p>The trigger handler logic will update the following field:</p><ul><li>Parent.Latest_Child_URL__c</li></ul><p>Based on the following formula field:</p><ul><li>Child.External_URL__c</li></ul><h3>Show me the code!</h3><p>First, let’s create an interface with the required methods for the Field Reader:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/179f5ab91299a3e8744d161021f77ef3/href">https://medium.com/media/179f5ab91299a3e8744d161021f77ef3/href</a></iframe><p>Using this interface, let’s create a class that reads values from a SObject record, using standard <strong>SObject</strong> methods:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e85996965cfef1f662db0cac368e337e/href">https://medium.com/media/e85996965cfef1f662db0cac368e337e/href</a></iframe><p>Also, using this interface, let’s create a class that will allow us to mock the <strong>read-only</strong> fields:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/29adb49a9c3b2720714a769abe6d0cca/href">https://medium.com/media/29adb49a9c3b2720714a769abe6d0cca/href</a></iframe><h4>Getters</h4><p>To respect the injected dependency, these methods must be present on both the real instance of the field reader ( FieldReader ) and the mock instance of the field reader ( MockFieldReader ).</p><p>public Object getFieldValue(SObject record, String fieldName)</p><p>This method is used to retrieve the mock values of formula fields. It returns an Object that can later be cast as different types, such as String, Number, Id, etc.</p><p>public SObject getFieldRecord(SObject record, String fieldName)</p><p>This method is used to retrieve the mock values that represent a single record. It returns a SObject.</p><p>public List getFieldRecords(SObject record, String fieldName)</p><p>This method is used to retrieve the mock values that represent a list of records, such as a child relationship. It returns a list of SObjects.</p><h4>Setter</h4><p>There’s only one method used to set the values, and it’s only present on the mock instance of the field reader ( MockFieldReader ).</p><p>public void addValueToField(SObject record, String field, Object value)</p><p>This method adds the field/value pair to a map of mocked values, indexed by the record Id.</p><h4>Examples</h4><p>In the <a href="https://github.com/gitmatheus/MockFieldReader">repository on Github</a>, you will find a trigger handler class and its respective test class with the usage of this Mock Field Reader.</p><p>Snippet from the <strong>AccountTriggerHandler</strong>: pay attention to how the following methods are being used:</p><p>fieldReader.getFieldRecords(parentAndChildAccount, &#39;Child_Accounts__r&#39;);<br>fieldReader.getFieldValue(latestChild, &#39;External_URL__c&#39;);</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/714342a16653b77732a1e99a90828cf4/href">https://medium.com/media/714342a16653b77732a1e99a90828cf4/href</a></iframe><p>And in the <strong>AccountTriggerHandlerTest</strong> you can see how these <strong>read-only</strong> fields can be mocked:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dbfe2bd9f8547d9061246901f839797e/href">https://medium.com/media/dbfe2bd9f8547d9061246901f839797e/href</a></iframe><p>With this code and the Mock Field Reader, it becomes easy to mock <strong>read-only</strong> fields used in the tests.</p><p>I hope that helps!</p><p><em>Created by Matheus Gonçalves. Originally published on </em><a href="https://matheus.dev/how-to-mock-formulas-and-non-writable-relationships-in-apex/"><em>matheus.dev</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2aca1595aab4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript Developer I Certification: Empowering JavaScript Developers to Build on Salesforce]]></title>
            <link>https://medium.com/trailhead/salesforce-javascript-developer-i-certification-decfc3b5f1aa?source=rss-fbf3d2870161------2</link>
            <guid isPermaLink="false">https://medium.com/p/decfc3b5f1aa</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[certification]]></category>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[careers]]></category>
            <category><![CDATA[trailhead]]></category>
            <dc:creator><![CDATA[Matheus Gonçalves]]></dc:creator>
            <pubDate>Tue, 23 Jun 2020 19:51:01 GMT</pubDate>
            <atom:updated>2021-12-21T18:59:58.805Z</atom:updated>
            <content:encoded><![CDATA[<h4><a href="https://trailhead.salesforce.com/credentials/developeroverview?&amp;utm_source=medium&amp;utm_medium=blog-link&amp;utm_campaign=trailblazer_blog&amp;utm_content=blog-tdx20_new_javascript_cert">Salesforce Credentials</a> are designed to help you unlock the door to new career opportunities. Now, for the first time, we’re empowering JavaScript developers to showcase their ability to build on the Salesforce Platform.</h4><figure><img alt="Trailhead characters Astro, Earnie, and Hootie outdoors looking at the Salesforce Certified JavaScript Developer I logo." src="https://cdn-images-1.medium.com/max/1024/1*kNKqc17GU_fOUcqPh3_qxw.png" /></figure><p><strong><em>T o keep things fresh, we’ve updated this, one of our most popular posts. </em></strong><a href="https://www.salesforce.com/blog/salesforce-javascript-developer-certification/"><strong><em>See the latest version here</em></strong></a><strong><em>.</em></strong></p><p>Now is the <a href="https://medium.com/trailhead/5-reasons-to-get-salesforce-certified-4853b6bb3464?source=friends_link&amp;sk=53cf2d1d3cc3cd1a9c5a9ff604c32cfc">time to become Salesforce-certified</a>. With 48 resume-worthy Salesforce Credentials and counting — including <a href="https://trailhead.salesforce.com/credentials/?&amp;utm_source=medium&amp;utm_medium=blog-link&amp;utm_campaign=trailblazer_blog&amp;utm_content=blog-tdx20_new_javascript_cert">30 certifications</a> and <a href="https://trailhead.salesforce.com/superbadges?&amp;utm_source=medium&amp;utm_medium=blog-link&amp;utm_campaign=trailblazer_blog&amp;utm_content=blog-tdx20_new_javascript_cert">18 superbadges</a> — there are endless opportunities to showcase your experience with Salesforce and take your career to the next level.</p><p>More than ever, companies need Salesforce-skilled talent to help them drive their digital transformation. No matter your role, Salesforce Credentials allow you to prove that you’re the expert of your domain and showcase to current and future employers that you have the knowledge and skills to help them go digital fast.</p><p>Approximately <a href="https://medium.com/javascript-scene/how-popular-is-javascript-in-2019-823712f7c4b1">95% of all websites use JavaScript</a> and there are <a href="https://jaxenter.com/dev-report-javascript-164201.html">more than 11 million JavaScript developers worldwide</a>.</p><p>That’s why we’re so excited to introduce the <a href="https://trailhead.salesforce.com/credentials/javascriptdeveloperi?&amp;utm_source=medium&amp;utm_medium=blog-link&amp;utm_campaign=trailblazer_blog&amp;utm_content=blog-tdx20_new_javascript_cert"><strong>Salesforce Certified JavaScript Developer I</strong></a><strong> </strong>certification<strong>. </strong>This new certification validates two core competencies:</p><ol><li>Standard JavaScript developer skills</li><li>Hands-on development skills for those working with JavaScript-related technologies, like Lightning Web Components</li></ol><h3>Your path to JavaScript certification</h3><p>To maximize your learning and showcase your expertise, the JavaScript Developer I Certification is comprised of two parts that you can take in either order.</p><figure><img alt="Path to the certification: the LWC Superbadge and the JS exam combined lead to the JavaScript Developer I cert." src="https://cdn-images-1.medium.com/max/1024/1*jGPC8__2RmsyIhqN77rtQA.png" /></figure><ul><li><a href="https://trailhead.salesforce.com/help?article=Salesforce-Certified-JavaScript-Developer-I-Exam-Guide&amp;&amp;utm_source=medium&amp;utm_medium=blog-link&amp;utm_campaign=trailblazer_blog&amp;utm_content=blog-tdx20_new_javascript_cert"><strong>JavaScript Developer I proctored multiple-choice exam</strong></a> <strong>— </strong>Intended for Trailblazers with 1–2 years of experience in developing front-end and/or back-end JavaScript applications for the web stack. The ideal candidate should be able to use JavaScript-specific design patterns for programming and can combine JavaScript with CSS, HTML, and other markup languages.</li><li><a href="https://trailhead.salesforce.com/content/learn/superbadges/superbadge_lwc_specialist?&amp;utm_source=medium&amp;utm_medium=blog-link&amp;utm_campaign=trailblazer_blog&amp;utm_content=blog-tdx20_new_javascript_cert"><strong>Lightning Web Components Specialist superbadge</strong></a> <strong>— </strong>Validates Trailblazers’ expertise in developing fully functional Lightning Web Components. The ideal candidate should be able to use JavaScript and Salesforce Lightning Design System to create base and custom Lightning Web Components, using Lightning Data Service to manipulate Salesforce data and creating Lightning Message Service channels to communicate across the Document Object Model (DOM).</li></ul><h3>Learn foundational skills before unlocking the superbadge</h3><p>To guide you on your path to earning the <a href="https://trailhead.salesforce.com/content/learn/superbadges/superbadge_lwc_specialist?&amp;utm_source=medium&amp;utm_medium=blog-link&amp;utm_campaign=trailblazer_blog&amp;utm_content=blog-tdx20_new_javascript_cert">Lightning Web Components Specialist</a> superbadge, we’ve developed a series of core badges to provide you with the foundational knowledge needed to become a successful Salesforce Certified JavaScript Developer.</p><ol><li><a href="https://trailhead.salesforce.com/content/learn/projects/quick-start-lightning-web-components?&amp;utm_source=medium&amp;utm_medium=blog-link&amp;utm_campaign=trailblazer_blog&amp;utm_content=blog-tdx20_new_javascript_cert"><strong>Quick Start: Lightning Web Components</strong></a><strong> — </strong>Set up your developer environment, tools, and editor, and create your first Lightning Web Component.</li><li><a href="https://trailhead.salesforce.com/content/learn/modules/lightning-web-components-and-salesforce-data?&amp;utm_source=medium&amp;utm_medium=blog-link&amp;utm_campaign=trailblazer_blog&amp;utm_content=blog-tdx20_new_javascript_cert"><strong>Lightning Web Components and Salesforce Data</strong></a><strong> — </strong>Develop Lightning Web Components that interact with data in your Salesforce org, including using Apex and server errors handling.</li><li><a href="https://trailhead.salesforce.com/content/learn/modules/test-lightning-web-components?&amp;utm_source=medium&amp;utm_medium=blog-link&amp;utm_campaign=trailblazer_blog&amp;utm_content=blog-tdx20_new_javascript_cert"><strong>Testing Lightning Web Components</strong></a><strong> — </strong>Set up the Jest testing framework and start testing Lightning Web Components, including tests for Wire services, mocking base, and custom components.</li><li><a href="https://trailhead.salesforce.com/content/learn/modules/coding-for-web-accessibility?&amp;utm_source=medium&amp;utm_medium=blog-link&amp;utm_campaign=trailblazer_blog&amp;utm_content=blog-tdx20_new_javascript_cert"><strong>Coding for Web Accessibility</strong></a><strong> — </strong>Write code to build accessible user interfaces.</li></ol><p><strong>🌟 Pro tip: </strong>The <a href="https://trailhead.salesforce.com/help?article=Lightning-Web-Components-Specialist-Superbadge-Trailhead-Challenge-Help&amp;&amp;utm_source=medium&amp;utm_medium=blog-link&amp;utm_campaign=trailblazer_blog&amp;utm_content=blog-tdx20_new_javascript_cert">Lightning Web Components Specialist Superbadge: Trailhead Challenge Help</a> is designed to assist Trailblazers with FAQs about this superbadge, including links to helpful articles and explanations of different troubleshooting techniques.</p><h3>Prepare for your certification with guided Trailhead resources</h3><p>On the road to JavaScript Developer Certification, there’s no shortage of Trailhead resources to help you prepare:</p><ol><li><strong>Review the </strong><a href="https://trailhead.salesforce.com/help?article=Salesforce-Certified-JavaScript-Developer-I-Exam-Guide&amp;&amp;utm_source=medium&amp;utm_medium=blog-link&amp;utm_campaign=trailblazer_blog&amp;utm_content=blog-tdx20_new_javascript_cert"><strong>Salesforce Certified JavaScript Developer I exam guide</strong></a><strong> — </strong>This guide includes recommended training, resources, and relevant Trailhead modules.</li><li><strong>Complete the </strong><a href="https://trailhead.salesforce.com/users/00550000006yDdKAAU/trailmixes/prepare-for-your-salesforce-javascript-developer-i-credential?&amp;utm_source=medium&amp;utm_medium=blog-link&amp;utm_campaign=trailblazer_blog&amp;utm_content=blog-tdx20_new_javascript_cert"><strong>Prepare for Your Salesforce JavaScript Developer I Credential</strong></a><strong> trailmix and the </strong><a href="https://trailhead.salesforce.com/content/learn/trails/study-for-the-salesforce-javascript-developer-i-exam?&amp;utm_source=medium&amp;utm_medium=blog-link&amp;utm_campaign=trailblazer_blog&amp;utm_content=blog-tdx20_new_javascript_cert"><strong>Study for the JavaScript Developer I Exam</strong></a><strong> trail — </strong>We’ve curated step-by-step learning paths to help you understand and apply the key concepts you’ll need to prove your skills and become a <a href="https://twitter.com/hashtag/certifiedpro">#CertifiedPro</a>.</li><li><strong>Take the </strong><a href="https://trailhead.salesforce.com/academy/classes/crt-600-certification-preparation-for-salesforce-javascript-developer-i/?&amp;utm_source=medium&amp;utm_medium=blog-link&amp;utm_campaign=trailblazer_blog&amp;utm_content=blog-tdx20_new_javascript_cert"><strong>Certification Preparation for JavaScript Developer I (CRT-600)</strong></a><strong> course — </strong>We’re excited to introduce this brand new course to supplement your self-studying on Trailhead and reinforce your knowledge of key features and concepts of the JavaScript programming language.</li><li><strong>Join the </strong><a href="https://trailblazer.salesforce.com/?&amp;utm_source=medium&amp;utm_medium=blog-link&amp;utm_campaign=trailblazer_blog&amp;utm_content=blog-tdx20_new_javascript_cert"><strong>Trailblazer Community</strong></a><strong> — </strong>When getting certified, collaboration is key, and the Trailblazer Community is a great place to start. Engage for help on the trails, to join a user group in your area, to find a study partner/mentor, and to connect with other Trailblazers from around the globe with similar experiences and challenges.</li></ol><h3>Ready to earn your JavaScript certification?</h3><p>Feeling inspired to be among the first to become a Salesforce Certified JavaScript Developer? It’s time to dive in! Head over to the <a href="https://trailhead.salesforce.com/credentials/javascriptdeveloperi?&amp;utm_source=medium&amp;utm_medium=blog-link&amp;utm_campaign=trailblazer_blog&amp;utm_content=blog-tdx20_new_javascript_cert">Salesforce Certified JavaScript Developer I Credential</a> page for all the details on this exciting new certification, including access to all of the study resources available to you on Trailhead.</p><p>And don’t forget to shout out your success on social using <a href="https://twitter.com/hashtag/certifiedpro">#CertifiedPro</a> so we can follow your success!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=decfc3b5f1aa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/trailhead/salesforce-javascript-developer-i-certification-decfc3b5f1aa">JavaScript Developer I Certification: Empowering JavaScript Developers to Build on Salesforce</a> was originally published in <a href="https://medium.com/trailhead">The Trailblazer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to query for Salesforce Apex classes code coverage?]]></title>
            <link>https://matheusdev.medium.com/how-to-query-for-salesforce-apex-classes-code-coverage-488ee6f51073?source=rss-fbf3d2870161------2</link>
            <guid isPermaLink="false">https://medium.com/p/488ee6f51073</guid>
            <category><![CDATA[code-coverage]]></category>
            <category><![CDATA[apex]]></category>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Matheus Gonçalves]]></dc:creator>
            <pubDate>Sat, 04 Apr 2020 19:08:46 GMT</pubDate>
            <atom:updated>2021-03-08T16:22:50.246Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1kdt3hKn1aFmrP_GKUrRaQ.jpeg" /></figure><h3>How to query for Salesforce Apex classes code coverage? — Matheus Gonçalves</h3><p>In Salesforce Orgs, code coverage percentage is a calculation of the number of covered lines divided by the sum of the number of covered lines and uncovered lines.</p><p>In addition to ensuring the quality of your code, unit tests enable you to meet the code coverage requirements for deploying or packaging Apex. To deploy Apex or package it for the Salesforce AppExchange, unit tests must cover at least 75% of your Apex code, and those tests must pass.</p><p>After running tests, you can view code coverage information in the Tests tab of the Developer Console. The code coverage panel includes coverage information for each Apex class and the overall coverage for all Apex code in your organization.</p><p>However, you can also use SOQL queries with Tooling API as an alternative way of checking code coverage and a quick way to get more details. Let’s see how it works:</p><h3>Inspecting Code Coverage</h3><h3>Step 1 — Get your org’s base URL:</h3><p>If you know what’s your Org’s base URL (<em>you can get it from your browser as well</em>), please jump to step 2.</p><ul><li>From Developer Console, open the Debug menu, then select the option “Open Execute Anonymous Window (CTRL+E)</li><li>Enter the following Apex Code:</li></ul><p>String baseURL = &#39;https://&#39; + System.URL.getSalesforceBaseUrl().getHost();<br>System.debug(baseURL);</p><ul><li>Click the button [Execute]</li><li>Go to your Logs tab on the bottom of the page</li><li>Copy the full Base URL, including <strong><em>https://</em></strong></li></ul><h3>Step 2 — Now you know your base URL, create a Remote Site Setting</h3><ul><li>From Setup, enter Remote Site Settings in the Quick Find box, then select Remote Site Settings.</li><li>Click New Remote Site.</li><li>Enter a descriptive term for the Remote Site Name.</li><li>Enter the URL for the remote site.</li><li>Optionally, enter a description of the site.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/0*wJ1N3sZmmm1XfmhH.png" /></figure><ul><li>Click Save.</li><li>Just in case, create a second Remote Site Settings for the URL in the “Visual.force.com” format:</li><li><a href="https://c.xx99.visual.force.com/">https://c.<strong>xx99</strong>.visual.force.com</a> — where xx99 is the code of your org’s instance.</li></ul><h3>Step 3 — Get the JSON file for the Code Coverage Wrapper</h3><ul><li>Go back to the Developer Console, open the Debug menu, then select the option “Open Execute Anonymous Window (CTRL+E)</li><li>Enter the following Apex Code:</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a5aca67d845dd438abff47550873b50/href">https://medium.com/media/3a5aca67d845dd438abff47550873b50/href</a></iframe><ul><li>Click the button [Execute]</li><li>Go to your Logs tab on the bottom of the page</li><li>Copy the full JSON result</li><li>Please note you will need to remove any text before the first <strong>“{“</strong> bracket.</li><li>Eg.: “<em>hh:mm:ss:999 USER_DEBUG [99]|DEBUG|</em>“</li><li>Go to the website JSON2Apex: <a href="https://json2apex.herokuapp.com/">https://json2apex.herokuapp.com/</a></li><li>Paste your JSON file</li><li>Enter the name for the generated class (here, we will use <strong>CodeCoverageWrapper</strong>)</li><li>Click the button <strong>[Create Apex]</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wDkbq0DaSF30gzON.png" /></figure><ul><li>Download the generated zip file that contains the Wrapper class plus the Test class.</li><li>Extract the files</li><li>Open the files with your preferred text editor</li><li>Check if everything looks good, and add these classes to your Salesforce org as new classes.</li></ul><p>This is how it looks like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ec48cde0a4ebabfdc33197e11bda4390/href">https://medium.com/media/ec48cde0a4ebabfdc33197e11bda4390/href</a></iframe><h3>Step 4 — Create a Helper Class</h3><ul><li>Create the following class, that contains a method that will query and return information about the Code Coverage</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/258152743a943b0fdfb6b6b079cefe13/href">https://medium.com/media/258152743a943b0fdfb6b6b079cefe13/href</a></iframe><p><strong>Don’t forget to write the test class for it.</strong></p><h3>Step 5 — Create a Controller and a Page to display the Code Coverage</h3><ul><li>Create the following class, that contains the logic for the page</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ca67bdc3985cd78c53c1701a4c546ab7/href">https://medium.com/media/ca67bdc3985cd78c53c1701a4c546ab7/href</a></iframe><p>Create the following page, using the controller we just created.</p><ul><li>Please note we’re leveraging <a href="https://www.lightningdesignsystem.com/getting-started/"><strong>Salesforce Lightning Design System</strong></a>;</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/336ff552a14b6be09da53287651132f4/href">https://medium.com/media/336ff552a14b6be09da53287651132f4/href</a></iframe><p>The page has two buttons. One to sort the results by Class / Trigger name, and another button to sort the results by Code Coverage.</p><p>This is how it looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*pXJ_KDg6wQLrqWg7lttXFQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*phB_1UuTWb-WkCUwepIYTw.png" /></figure><h3>Final Considerations</h3><p>You can follow the same logic to use the Tooling API whenever you need to query exposed metadata used in developer tooling that you can access through REST or SOAP.</p><p>Also, the method <strong><em>sortCodeCoverageMapByCoverage</em></strong> from <strong><em>CodeCoverageHelper</em></strong> is quite handy and can be used as an example for situations when you need to sort Maps by its values. In this case, sort the Code Coverage percentage value.</p><p>Just don’t forget to adapt the Wrapper and the Comparable.</p><p>You can find all code used for this project in my GitHub account, at <a href="http://github.com/toadgeek/QueryCodeCoverage">github.com/gitmatheus/QueryCodeCoverage</a></p><p>I hope you enjoyed the ride and learned something new today.</p><p>See you next time.</p><p><em>This article was originally posted at </em><a href="https://matheusgoncalves.com/how-to-query-salesforce-code-coverage/"><em>matheus.dev</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=488ee6f51073" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unit Test: Can we mock relationships in Apex?]]></title>
            <link>https://matheusdev.medium.com/unit-test-can-we-mock-relationships-in-apex-b69bc9f8601f?source=rss-fbf3d2870161------2</link>
            <guid isPermaLink="false">https://medium.com/p/b69bc9f8601f</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[mock]]></category>
            <category><![CDATA[apex]]></category>
            <category><![CDATA[salesforce]]></category>
            <dc:creator><![CDATA[Matheus Gonçalves]]></dc:creator>
            <pubDate>Tue, 31 Mar 2020 23:15:53 GMT</pubDate>
            <atom:updated>2021-07-22T21:06:26.504Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WCUtZI6wammO8qZKjdNIag.jpeg" /></figure><p>I’ve been trying to use some of my spare time to help my fellow Salesforce Developers in our community. And one of the best places to do so, is <a href="https://salesforce.stackexchange.com/">Salesforce Stack Exchange</a>.</p><p>And a few days ago someone posted the <a href="https://salesforce.stackexchange.com/questions/215326/can-we-mock-relationships-in-apex/">following question</a>:</p><blockquote>How can I write a test method without actually doing the query (to speed up test run times)? As far as I know, the only way to return relationships more than one level deep is to query for them. I know ApexMock has IDGenerator but cannot see how I can use it for this use case?</blockquote><p>Well, can we mock relationships in Apex to improve a test’s performance?</p><p>And the answer is <strong>yes, it’s possible</strong>. I’m going to explain how to achieve that in incremental steps, to try to simplify the concept.</p><p>You can mock virtually any relationship if you use a Mock Data Layer Pattern.</p><p>Imagining the scenario presented by the developer <a href="https://salesforce.stackexchange.com/questions/215326/can-we-mock-relationships-in-apex/">in that question</a>, you could add an Interface to your main class. Let’s call it IDataLayer. Add this new interface to the main class (here, called <strong>DataLayerHandler.cls</strong>)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/25b3e329ede9b13141045658045e0961/href">https://medium.com/media/25b3e329ede9b13141045658045e0961/href</a></iframe><p>Now, in the same class, let’s create an inner class for this data layer, implementing the Interface you just created:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/04067eb78934ecab0f4a499311456a7f/href">https://medium.com/media/04067eb78934ecab0f4a499311456a7f/href</a></iframe><p>Ok, now how to access it? We need to create an instance of this DataLayer, and we will use the DataLayerHandler Class constructor for that. This is really important, I’ll explain it below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/56838720135fec1f6e61b2998fe959de/href">https://medium.com/media/56838720135fec1f6e61b2998fe959de/href</a></iframe><p>But why do all of that?! And this is the magic: because now you can pass a MOCK version of the data layer to your class to use!! Given this handler class, let’s create a test class and a mock class, implementing the same interface:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/95b3b9c243ab4fe7fdda01f3787e35a7/href">https://medium.com/media/95b3b9c243ab4fe7fdda01f3787e35a7/href</a></iframe><p>With the mock version of the data layer, you can start creating your mock records. Use the method <strong><em>getFakeId(Schema.SObjectType type)</em></strong> to create Ids to your mock records:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1adea1e5d640deea38c69e5f023262a4/href">https://medium.com/media/1adea1e5d640deea38c69e5f023262a4/href</a></iframe><p>There you go. This way you can mock several different types of relationships.</p><p>This is an extremely useful pattern and allow you to test your logic in different scenarios without running queries, without hitting the database. It’s a good way to improve your test performance.</p><p>Just don’t forget to create some bulkified tests as well.</p><p>I hope that helps!</p><p><em>This article was originally posted at </em><a href="https://matheusgoncalves.com/unit-test-mock-relationships-apex/"><em>matheus.dev</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b69bc9f8601f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Salesforce DX: Useful CLI Commands]]></title>
            <link>https://matheusdev.medium.com/salesforce-dx-useful-cli-commands-d802e9c50a2a?source=rss-fbf3d2870161------2</link>
            <guid isPermaLink="false">https://medium.com/p/d802e9c50a2a</guid>
            <category><![CDATA[salesforce-dx]]></category>
            <category><![CDATA[cli]]></category>
            <category><![CDATA[commands]]></category>
            <category><![CDATA[lwc]]></category>
            <category><![CDATA[sfdx]]></category>
            <dc:creator><![CDATA[Matheus Gonçalves]]></dc:creator>
            <pubDate>Tue, 31 Mar 2020 23:10:51 GMT</pubDate>
            <atom:updated>2020-03-31T23:19:04.411Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y_kvO3r1XVnciz3W-kwF_A.jpeg" /></figure><p>Salesforce DX is finally available and it is amazing! Now professional developers can build collaboratively with continuous delivery using <a href="https://developer.salesforce.com/platform/dx">Salesforce DX</a>, the open and integrated experience that makes development on the Salesforce Platform easy.</p><p>I strongly recommend you to watch this presentation, made by <a href="https://twitter.com/wadewegner">Wade Wegner</a>, with an introduction to Salesforce DX, talking about principles of Modern Software Delivery, how DX will improve the Developer Experience, some patterns and anti-patterns and how to adopt Salesforce DX:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FexZ3TICOzd8%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DexZ3TICOzd8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FexZ3TICOzd8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6762e92b2ba645bc1ec78c6a7f4743cf/href">https://medium.com/media/6762e92b2ba645bc1ec78c6a7f4743cf/href</a></iframe><p>Well, once you decide to switch, you’ll notice that you can use the <a href="https://developer.salesforce.com/tools/sfdxcli">Salesforce command-line interface (CLI)</a> for most Salesforce DX tasks. These tasks include authorizing a Dev Hub org, creating a scratch org, synchronizing source code between your scratch orgs and VCS, and running tests.<br>You can start using the CLI right after you install it.</p><p>The CLI commands are grouped into top-level topics. For example, the force top-level topic is divided into topics that group commands by functionality, such as the force:org commands to manage your orgs.</p><p>Run — help at each level to get more information.</p><p>sfdx --help // lists all top-level topics<br>sfdx force --help // lists all the topics under force<br>sfdx force:org --help // lists all the commands in the topic force:org<br>sfdx force:org:open --help // detailed info about the force:org:open command</p><p>Imagine you want to login to your Hub Org:</p><p>sfdx force:auth:web:login --setalias my-hub-org --instanceurl <a href="https://login.salesforce.com/">https://login.salesforce.com</a></p><p>Imagine now that you want to login to your sandbox:</p><p>sfdx force:auth:web:login --setalias my-sandbox --instanceurl <a href="https://test.salesforce.com/">https://test.salesforce.com</a></p><p>To set this alias as your current default:</p><p>sfdx force:config:set defaultusername=my-sandbox</p><p>Maybe you want to get a list to all orgs you’re connected to:</p><p>sfdx force:org:list</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/0*sWj53tSpH0v4qTNC.png" /></figure><p>To open one of these orgs:</p><p>sfdx force:org:open -u my-sandbox</p><p>To mark a scratch org for deletion:</p><p>sfdx force:org:delete -u my-sandbox</p><p>To <strong>remove an old hub org</strong> or non-scratch org from Salesforce DX org list, you need to manually clean up the DX configs in the local installation. It would be nice for this to be something in the actual CLI commands: the ability to clean up old orgs that are no longer needed. For the time being, use the following steps:</p><p>On <strong>Mac OS and Linux</strong>, you can find your DX config folder, called .sfdx, in your user home directory.</p><p>cd ~/.sfdx</p><p>On <strong>Windows</strong>, you can use</p><p>%USERPROFILE%\.sfdx</p><p>In that folder, there are a host of .json files, named for the username of the admin user you registered for that org. In my case, in this instance it was called mgoncalves@dx.pilot, so sure enough, there it was:</p><p>mgoncalves@dx.pilot.json</p><p>Inside the file or the hashes for a current access token, refresh token, and all the other OAuth goodness that allows DX to access your org. So I simply deleted that file:</p><p>&gt; rm mgoncalves@dx.pilot.json</p><p>That appears to have <strong>cleaned it all up</strong>.</p><p>To retrieve unpackaged Source Defined in a package.xml file (eg.: the file created by <a href="http://mavensmate.com/">MavensMate</a>):</p><p>sfdx force:mdapi:retrieve -r ./mdapipkg -u [your_username] -k ./package.xml</p><p>To retrieve an <a href="https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_retrieve_unman_pack.htm">unmanaged package you want to convert to Salesforce DX</a>:</p><p>sfdx force:mdapi:retrieve -s -r ./mdapipkg -u [your_username] -p</p><p>To convert the retrieved source Defined in a package.xml file: the first step is to unzip <strong>unpackaged.zip</strong> using a zip file management utility or from the command line. For example, on a Mac, double-click unpackaged.zip in Finder or type the following command on the command line:</p><p>unzip ./mdapipkg/unpackaged.zip -d ./mdapipkg/</p><p>Then convert the source code to the Salesforce DX project structure:</p><p>sfdx force:mdapi:convert -r ./mdapipkg</p><p>To create a scratch org, first <a href="https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs_def_file.htm">create a JSON file</a> with the or configuration. Then:</p><p>sfdx force:org:create -f project-scratch-def.json -a MyScratchOrg</p><p>To push changes, use a <strong>Force Push</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*z_32d5Ht6w3C342O.gif" /></figure><p>I mean, use this:</p><p>sfdx force:source:push -u MyScratchOrg</p><p>To push changes ignoring errors (<em>with great powers, great responsibilities. Be careful</em>):</p><p>sfdx force:source:push -u MyScratchOrg --ignorewarnings --forceoverwrite</p><p>For an even more powerful approach, you can retrieve and deploy code from/to a regular org. First, authorize the regular org using the login command we learned above. Then, choose one of the options below, depending on if you want or not to deploy Lightning/Aura Components:</p><p>sfdx force:source:retrieve -m CustomObject,ApexClass,ApexTrigger,ApexPage,CustomLabels</p><p>sfdx force:source:deploy -m CustomObject,ApexClass,ApexTrigger,ApexPage,CustomLabels</p><p>sfdx force:source:deploy -m CustomObject,ApexClass,ApexTrigger,ApexPage,CustomLabels,AuraDefinitionBundle</p><p>sfdx force:source:retrieve -m CustomObject,ApexClass,ApexTrigger,ApexPage,CustomLabels,AuraDefinitionBundle</p><p>Salesforce DX CLI is a powerful command-line interface, a tool that simplifies development and builds automation when working with your Salesforce org.</p><p>For even more information, run this command to view all available commands in the force topic.</p><p>sfdx force:doc:commands:list</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8597cbce0f6ea1af7c6127e8727e4f19/href">https://medium.com/media/8597cbce0f6ea1af7c6127e8727e4f19/href</a></iframe><p>See you next time.</p><p><em>This article was originally posted at </em><a href="https://matheusgoncalves.com/salesforce-dx-useful-cli-commands/"><em>matheus.dev</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d802e9c50a2a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to use Trailhead to Boost your Team's Knowledge]]></title>
            <link>https://matheusdev.medium.com/how-to-use-trailhead-to-boost-your-teams-knowledge-c4469a3fdcf0?source=rss-fbf3d2870161------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4469a3fdcf0</guid>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[trailhead]]></category>
            <category><![CDATA[boost]]></category>
            <category><![CDATA[knowledge]]></category>
            <dc:creator><![CDATA[Matheus Gonçalves]]></dc:creator>
            <pubDate>Tue, 31 Mar 2020 23:04:33 GMT</pubDate>
            <atom:updated>2020-03-31T23:36:38.917Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zeyalyLEgKI78yCjFtVNjQ.png" /></figure><p>This content was presented during <a href="https://www.salesforce.com/events/trailhead-live/atlanta/">Trailhead Live Atlanta</a>, on September 14th, 2017.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fzr4k49PzCBQ%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dzr4k49PzCBQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fzr4k49PzCBQ%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/a82d5223235358cb5ecddd667776d1d1/href">https://medium.com/media/a82d5223235358cb5ecddd667776d1d1/href</a></iframe><p>Some people say we never stop learning because life never stops teaching. Sometimes, the difference between a bad day and a good day is if we learned something.</p><p>It’s all about the joy of understanding. So, today let’s talk about <a href="https://trailhead.salesforce.com/en">Trailhead</a> and how to use it to boost your team’s knowledge!</p><p>In a nutshell, Trailhead is a fun way to learn <strong>Salesforce</strong>. And I mean it.</p><p>It’s an online learning platform based on gamification, so once you finish the units in a given module, you get a shiny new badge and level up your character.</p><p>Whether you’re an admin just starting out, a graduate fresh from college, a Salesforce user, or someone who loves to learn,<br>there’s something on Trailhead for you.</p><p>Watch the vídeo above to learn more about using Trailhead to improve your skills. Don’t forget to share it with your team!</p><p>See you next time.</p><p><em>This article was originally posted at </em><a href="https://matheusgoncalves.com/trailhead-to-boost-your-team-knowledge/"><em>matheus.dev</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4469a3fdcf0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to select the Salesforce release for a Scratch Org — Matheus Gonçalves]]></title>
            <link>https://matheusdev.medium.com/how-to-select-the-salesforce-release-for-a-scratch-org-matheus-gon%C3%A7alves-f265681d6bc5?source=rss-fbf3d2870161------2</link>
            <guid isPermaLink="false">https://medium.com/p/f265681d6bc5</guid>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[scratch-orgs]]></category>
            <category><![CDATA[cli]]></category>
            <category><![CDATA[sfdx]]></category>
            <dc:creator><![CDATA[Matheus Gonçalves]]></dc:creator>
            <pubDate>Mon, 29 Jul 2019 16:51:45 GMT</pubDate>
            <atom:updated>2020-04-04T19:08:25.148Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ylvvs3QsJuxkQIIx33opqw.jpeg" /></figure><h3>How to select the Salesforce release for a Scratch Org — Matheus Gonçalves</h3><p>Did you know you can specify the release (preview or previous) when creating a scratch org?</p><p>That is especially helpful when testing your code against future features in Preview orgs, but <a href="https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs_version_selection.htm">it’s even more than that</a>:</p><p>During every major Salesforce release, you have the opportunity to get early access to the release in your scratch orgs and sandboxes to test new customizations and features before your production org is upgraded. This is called the Salesforce Preview, and scratch orgs created on the upcoming release are called preview scratch orgs.</p><p>This way you not only can try out new features in an upcoming release, to check if they <strong>will fit your needs</strong> but also by running your applications in preview orgs, you can <strong>proactively</strong> check if your code is in good shape or if there will be a <strong>breaking change</strong>.</p><p>Then you can add any future bug to your backlog and plan your work accordingly, with fewer surprises.</p><p>Normally, you create scratch orgs that are the same version as the Dev Hub. However, during the major Salesforce release transition that happens three times a year, <strong>you can select the Salesforce release version</strong>, <em>Preview</em> or <em>Previous</em>, based on the version of your Dev Hub.</p><p>Prior to this change, you would have to create a trial Dev Hub on the upcoming version to create preview scratch orgs. Now you can use your existing Dev Hub that includes your existing scratch org active and daily limits.</p><p>Because previous and preview are all relative terms, your Dev Hub org version during the release transition determines their relative significance. Here’s what happens when you try to create a scratch org with one of the release values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*PoslU2ATVC4s3dGkw_1HYQ.png" /></figure><p><strong>Important note: If you don’t specify a release value, the scratch org version is the same version as the Dev Hub org.</strong></p><h3>Create a Scratch Org for a Specific Release</h3><p>You can specify the release version in the scratch org definition file or directly on the command line. Any option you issue on the command line overrides what you have defined in your scratch definition file.</p><p>Find out which instance your Dev Hub org is on: <a href="http://status.salesforce.com/">status.salesforce.com</a>.</p><p>Add the release option to your <a href="https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs_def_file_config_values.htm"><em>scratch org definition file</em></a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/34cb758cc4425876466869b19110fbdc/href">https://medium.com/media/34cb758cc4425876466869b19110fbdc/href</a></iframe><p>If you’re planning on using some sort of script to spin up a new scratch org, or you just prefer using the command line, you can specify the release value directly on the <strong>CLI</strong>!</p><p>Please note the use of the release keyword: <strong>release=Preview</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0259c646614f7e7778b779162888a2ef/href">https://medium.com/media/0259c646614f7e7778b779162888a2ef/href</a></iframe><p>If you’re creating a <strong>previous scratch org</strong> and you have upgraded the CLI to the pre-release version, be sure to set the apiVersion to match the scratch org version.</p><p>To set it globally for all DX projects:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ac717de458aa4f0dbf1c85ae91b9c5a6/href">https://medium.com/media/ac717de458aa4f0dbf1c85ae91b9c5a6/href</a></iframe><p>To set it on the command line:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/85ff1e29420abf13c29dab1f82fca36e/href">https://medium.com/media/85ff1e29420abf13c29dab1f82fca36e/href</a></iframe><h3>What If I Want to Create a Pre-Release Scratch Org?</h3><p>Pre-release is a very early build of the latest version of Salesforce that’s available before Salesforce Preview. It’s not built to handle scale and doesn’t come with any Salesforce Support service-level agreements (SLAs).</p><p>For this reason, the only way to create a pre-release scratch org is to sign up for a <a href="https://sfdc.co/RR-Pre-Release">pre-release trial Dev Hub org</a> (subject to availability).</p><p><em>Originally published at </em><a href="https://matheusgoncalves.com/how-to-select-the-salesforce-release-for-a-scratch-org/"><em>matheus.</em></a><em>dev on July 29, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f265681d6bc5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Best Practices When Deleting Salesforce Customizations]]></title>
            <link>https://matheusdev.medium.com/best-practices-when-deleting-salesforce-customizations-e387586e3df0?source=rss-fbf3d2870161------2</link>
            <guid isPermaLink="false">https://medium.com/p/e387586e3df0</guid>
            <category><![CDATA[cleanup]]></category>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[delete]]></category>
            <category><![CDATA[best-pratice]]></category>
            <dc:creator><![CDATA[Matheus Gonçalves]]></dc:creator>
            <pubDate>Fri, 22 Sep 2017 13:37:32 GMT</pubDate>
            <atom:updated>2020-04-04T19:07:51.467Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zh5X3Lion1ArkWbi2_RN-w.jpeg" /></figure><p>Your company has been a Salesforce customer for a while now. How old is your Org now? Five years? Ten? Chances are there are a bunch of customizations and technical debt lingering around your org that you no longer need. Business processes and priorities are constantly changing and some of the customizations you built just a few years ago may no longer be relevant. <a href="https://developer.salesforce.com/blogs/developer-relations/2017/01/time-clean-unneeded-salesforce-customizations.html">It’s time to move on and clean up your org</a>!</p><p>Let’s follow these <strong>best practices</strong> suggested by Christopher Marzilli, a Platform Success Specialist Director at Salesforce!</p><p>Your #AwesomeAdmin and Business Analysts have identified fields, objects, workflows, classes, triggers, processes, S-controls, etc… that are no longer needed. Now, what do you do next? Just “blow away” all the customizations and hope nothing goes wrong?</p><p><strong>Absolutely NOT!</strong></p><p>What you need is a decommissioning process by which Administrators, Developers, and Release Managers can safely remove Salesforce customizations without causing any disruption to the business. All the while having an easy process to restore any customizations that were thought to no longer be needed but, as it may come to light, are needed. This guide will review best practices for decommissioning many different types of Salesforce customizations including custom fields and objects, validation rules, Apex code, triggers, Visualforce pages, workflows, End-of-life features like S-Controls, and much more.</p><p>Assuming you have already identified a customization that is no longer needed, there are five steps that should be completed to safely decommission a customization in Salesforce:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/0*f2GD82mEsddSL2Y8.png" /></figure><h3>1. Research</h3><p>Once you have identified specific customizations that are no longer needed research needs to be completed to get a full view of where the customization is used. A sandbox is the best environment to start your research. Custom fields can be particularly difficult to research since they can be used in a variety of places. Here is a checklist of places to look for usage:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*4Jo-0o1-iUFS5ZaNi3ZYug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/84/0*iDIH-JmCk_r3oVHZ.png" /></figure><p><strong>Astro Tip</strong>: When you try to delete a custom field in Salesforce an error message will show if any validation rules, formula fields, workflows, processes, fieldsets or Apex reference the field. Try this in a sandbox environment as part of your research.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/0*RVIfnJNUQEhhEOSk.png" /></figure><p>Armed with the checklist above begin to review your org for possible uses and removal impacts of the customization. Try a few of these different ways to conduct your research:</p><ul><li>In a sandbox delete the customization. Salesforce will detect many different types of dependencies like validation rules and workflows.</li><li>If you are using a Source Control System like GIT or TFS try leveraging the search capabilities within those systems.<br> In the Developer Console use the “Search In Files” function located in the Edit Menu.</li><li>Leverage the <a href="https://developer.salesforce.com/page/Force.com_IDE">Force.com IDE</a> to inspect your code and metadata. The IDE has a text-based search function to help you find places where fields, classes or methods are referenced in code and config. If you are unfamiliar with how this can work check out AdminHero’s recent blog post on “<a href="https://www.adminhero.com/searching-salesforce-metadata-using-the-force-com-ide/">Searching Salesforce Metadata Using The Force.com IDE</a>”.</li><li>Use the Developer <a href="https://workbench.developerforce.com/">Workbench</a>, which like many other apps can leverage the Metadata API to search your metadata.<br> Check out the <a href="http://sftoolkit.co/">Salesforce Toolkit</a> for a variety of additional helpful tools.</li><li>Leverage <a href="https://appexchange.salesforce.com/listingDetail?listingId=a0N30000009wZM3EAM">SchemaSurfer</a>, an AppExchange app that provides a way to browse and explore object metadata inside of Salesforce</li></ul><p>You should be sure to test removing the customization in a sandbox. Check that all apex tests run successfully after removal. Don’t forget to test your inbound and outbound system integrations and to regression test any critical business processes after removal from a sandbox.</p><p>Once your research is complete you should have a list of all the places the customization is referenced with a plan on how to go about removing the customization and to update or remove any dependencies.</p><h3>2. Communicate</h3><p>Notify end users that the customization is being decommissioned. You can do this using a chatter post or as part of a regular newsletter. No matter how you send the communication, be sure to include a couple of key pieces of data:</p><ul><li>The customization being decommissioned</li><li>An explanation as to why it is being decommissioned</li><li>Information on if another customization replaces what is being decommissioned</li><li>A contact person to reach out to if anyone has any questions or concerns</li></ul><p>You should also label the customization so it can be clearly seen within the UI that it is being decommissioned and inform users what the label signifies. In the case of a custom fields, objects or workflows you can update their labels with “ <strong>OLD</strong>” or “ <strong>TBR</strong> “ for “To Be Removed.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/0*NJA6uFthB4-tFsxH.png" /></figure><p>With classes or triggers, whose names can’t change add comments at the top of the file to signify a change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gSoC-vaRPrhjOYMK.png" /></figure><p>Insert some text at the top of a Visualforce page to warn users of the pending removal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/0*JyUBL3Eup9woFSen.png" /></figure><p>Allow users some time (~15 to 30 days) after they have been notified to observe if any of their day-to-day work may be impacted.</p><p><strong>Note</strong>: Be mindful here of Customer and Partner Communities that may have access to fields, Visualforce pages and other customizations you are decommissioning. Notification and labels presented to these groups may need to vary versus an internal audience. In some cases, no notification or label may be required and you can move to the next step of restricting access.</p><h3>3. Restrict</h3><p>Now that you have reached the point where the changes have been communicated and clearly labeled and no one has reported any issues with the change it’s time to remove access to the customization from users. This is an important step because it may save you time as opposed to deleting the customization at this point. Having to bring back something after it has been deleting is much harder than simply re-authorizing access to the customization.</p><p>For many customizations like workflows, triggers, processes, and validation rules you can simply make them inactive. For customizations like custom fields and objects, you can leverage Field Level Security and Profiles to ensure no users have access to the fields or objects. You can also remove fields, Visualforce components and Lighting components from apps and page layouts. Rights to Visualforce pages and apps can also be revoked via profiles.</p><h3>4. Monitor</h3><p>Now that access has been restricted the next step is to institute a waiting period of ~15 to 90 days as a safeguard before final removal.</p><p>In the case of custom fields and objects, make a backup of their data before and after the monitoring period so you can check for any change in the data. You can also use Field History here if you have available fields for tracking.</p><p>Be sure an Administrator or Developer has an action item scheduled at the end of the waiting period to do a final examination and ensure the customization is no longer being used.</p><h3>5. Decommission</h3><p>Time to remove your customization from production. At this point, you should have notified all users, labeled the customization appropriately, run through tests in your sandbox environments and restricted access to the customization for a period of time. While you should follow your standard lifecycle (SDLC) here are a few items to include when decommissioning a customization.</p><p>Start by backing up the customizations metadata and data (if any). To backup metadata you can use your Force.com IDE which can download metadata in the form of an XML file. This can be stored on a file system but an even better solution is to use a Source Control System like GIT to store code and config changes in your org. Data can be backed up in a variety of ways from exporting reports to leveraging the data loader to pull down a CSV file of the data.</p><p>Now that you have backed up the customizations metadata and data you are ready to delete the customization from your Org! Unfortunately, changesets can’t be used to delete customizations in Salesforce. So for the most part Administrators will have to leverage Setup to delete customizations. Alternatively, you can leverage the <a href="https://developer.salesforce.com/docs/atlas.en-us.daas.meta/daas/meta_development.htm">Force.com ANT Migration tool</a> with a <a href="https://developer.salesforce.com/docs/atlas.en-us.daas.meta/daas/daas_destructive_changes.htm">destructiveChanges.xml</a> file to remove changes or one of the many <a href="https://appexchange.salesforce.com/results?keywords=deployment">3rd party deployment apps</a> available. In either case, you have reached the final step of removing the customization from production.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*-mU7fxrknRs5RbrO.jpg" /></figure><h3>Deleting Data</h3><p>The Salesforce data deletion mechanism can have a profound effect on the performance of large data volumes. Salesforce uses a Recycle Bin metaphor for data that users delete. Instead of removing the data, Salesforce flags the data as deleted and makes it visible through the Recycle Bin. This process is called soft deletion. While the data is soft deleted, it still affects database performance because the data is still resident, and deleted records have to be excluded from any queries.</p><p>The data stays in the Recycle Bin for 15 days, or until the Recycle Bin grows to a specific size. The data is then physically deleted from the database after 15 days; when the size limit is reached; or when the Recycle Bin is emptied using the UI, the API, or Apex. See <a href="https://help.salesforce.com/articleView?id=home_delete.htm&amp;type=0">View and Purge the Recycle Bin.</a></p><p>In addition, the Bulk API supports a hard delete (physical delete) option, which allows records to bypass the Recycle Bin and become immediately available for deletion. We recommend that you use the Bulk API’s hard delete function to delete large data volumes.</p><p>If you want to delete records in a sandbox organization’s custom objects immediately, you can try to truncate those custom objects. You can contact Salesforce Customer Support for assistance with this task.</p><p>Congratulations! If you followed these best practices, then you have safely removed unneeded technical debt from your Org. You, your company and your Org are better for it! Now go off and build <a href="https://trailhead.salesforce.com/project/workshop-battle-station">something cool</a>!</p><p>And don’t forget to check out the great ideas available on <a href="https://trailhead.salesforce.com/en/search?keywords=build">Trailhead</a>! 😉</p><p>See you next time.</p><p><em>Originally published at </em><a href="https://matheusgoncalves.com/best-practices-deleting-salesforce-customizations/"><em>matheus.dev</em></a><em> on September 22, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e387586e3df0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>