Close Menu
SalesforceCodex
    Facebook X (Twitter) Instagram
    Trending
    • Unlock the Power of Vibe Coding in Salesforce
    • How to Implement Dynamic Queueable Chaining in Salesforce Apex
    • How to Implement Basic Queueable Chaining in Salesforce Apex
    • How to Suppress PMD Warnings in Salesforce Apex
    • Top 10 PMD Issues Salesforce Developers Should Focus on in Apex
    • How to Use Graph API for Outlook-Salesforce Connection
    • Enhancing Performance with File Compression in Apex
    • Salesforce Spring ’25 Release: Top Flow Enhancements You Need to Know
    Facebook X (Twitter) Instagram
    SalesforceCodex
    Subscribe
    Friday, May 9
    • Home
    • Architecture
    • Salesforce
      • News
      • Apex
      • Integration
      • Books Testimonial
    • Questions
    • Certification
      • How to Prepare for Salesforce Integration Architect Exam
      • Certification Coupons
    • Integration Posts
    • Downloads
    • About Us
      • Privacy Policy
    SalesforceCodex
    Home»Salesforce»How to Remove Customer Details After Refreshing Salesforce Org

    How to Remove Customer Details After Refreshing Salesforce Org

    Dhanik Lal SahniBy Dhanik Lal SahniSeptember 16, 2024No Comments3 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr Email
    How to Remove Customer Details After Refreshing Salesforce Org
    Share
    Facebook Twitter LinkedIn Pinterest Email

    Salesforce supports four types of Sandboxes. These sandboxes should be refreshed periodically to get updated metadata from the production org. Customer data is copied to the org when a full-copy sandbox is refreshed. We should remove customer demographic data from the Sandbox org. This post will explain how to remove customer details after creating or refreshing Salesforce org from production.

    Why should we remove customer data?

    When we have customer data in UAT or full copy sandbox org, the testing team might send a test email or a text to customers’ mobile phones. Customers can complain about this, and there might be a legal issue with sharing their details. Sometimes, the testing team can send an email with new policies that even the business has not published for the market. This can lead to big financial issues for the company.

    Steps to Remove Customer Data from Sandbox

    1. Identify Objects for Customer Data
    2. Create Apex Job for Running After Sandbox Refresh
    3. Create a Sandbox for testing

    1. Identify Objects for Customer Data

    First, we must identify customer data that needs to be removed or changed. Once we identify customer data, we find out which objects and fields store it in Salesforce objects. We then prepare a list with each object and its field for data removal or changes.

    2. Create Apex Job for Running After Sandbox Refresh

    Salesforce’s SandboxPostCopy interface is designed to automatically execute custom logic after a sandbox is created or refreshed. This interface is invoked only once after the sandbox is fully refreshed or created.

    We can use this SandboxPostCopy interface to

    1. Create or modify user detail
    2. Assign Profile/Permission set to user
    3. Resetting data for testing
    4. Activating integration for specific use cases

    We will use this interface to replace/remove customer data. As we have a list of fields and objects where data needs to be changed, we will create a batch apex to update these data. A standard apex can throw a limit exception, as data in production can be high. We can also use Bulikified flow for this. For this post, I used a batch apex to update the information. In this batch apex, we will update the email and phone fields of the Account and Contact objects.

    Create a test class for the above batch apex. They are required to be deployed in productions.

    As these classes will be used in production while setting up sandbox refresh, we will deploy the above apex classes to production org.

    3. Create a Sandbox for testing

    Once we deploy changes to production, we can test them by creating a sandbox org. Let us create a UAT1 sandbox from production.

    Salesforce Org Refresh- Create Sandbox

    After this, put the Apex class name that will be called after Sandbox is refreshed or created.

    Refreshing Salesforce Org - Put Apex Class

    Once Sandbox is refreshed, you can check account and contact data or whatever customer data you want to replace.

    Refreshing Salesforce Org - Clean Data in Salesforce

    Summary

    SandboxPostCopy interface lets developers and administrators automate specific actions immediately following the copy process, ensuring the sandbox is configured correctly. This feature simplifies post-sandbox-creation tasks and provides a consistent environment setup across different sandbox environments.

    References

    • SandboxPostCopy Interface
    • Auto-Populate Salesforce Sandboxes with Sample Records

    Related Posts

    • How to Integrate Google reCaptcha v3 into the Salesforce Experience Site
    • The Ultimate Checklist for Efficiently Querying Large Data Sets
    • Ultimate Guide to Integrate Stripe with Salesforce CRM
    • How to Seamlessly Integrate Shopify with Salesforce
    • Ultimate Guide to URL Accessibility in LWC

    Need Help?

    If you need help implementing this feature, connect with me on my LinkedIn profile, Dhanik Lal Sahni.

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleHow to Elevate Your Career to Salesforce Architect
    Next Article Best Practices to Avoid Hardcoding in Apex for Cleaner Salesforce Code
    Dhanik Lal Sahni
    • Website
    • Facebook
    • X (Twitter)

    With over 18 years of experience in web-based application development, I specialize in Salesforce technology and its ecosystem. My journey has equipped me with expertise in a diverse range of technologies including .NET, .NET Core, MS Dynamics CRM, Azure, Oracle, and SQL Server. I am dedicated to staying at the forefront of technological advancements and continuously researching new developments in the Salesforce realm. My focus remains on leveraging technology to create innovative solutions that drive business success.

    Related Posts

    By Dhanik Lal Sahni6 Mins Read

    Unlock the Power of Vibe Coding in Salesforce

    April 30, 2025
    By Dhanik Lal Sahni5 Mins Read

    How to Implement Dynamic Queueable Chaining in Salesforce Apex

    April 21, 2025
    By Dhanik Lal Sahni5 Mins Read

    How to Implement Basic Queueable Chaining in Salesforce Apex

    March 31, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Ranked #1 SALESFORCE DEVELOPER BLOG BY SALESFORCEBEN.COM
    Featured on Top Salesforce Developer Blog By ApexHours
    Recent Posts
    • Unlock the Power of Vibe Coding in Salesforce
    • How to Implement Dynamic Queueable Chaining in Salesforce Apex
    • How to Implement Basic Queueable Chaining in Salesforce Apex
    • How to Suppress PMD Warnings in Salesforce Apex
    • Top 10 PMD Issues Salesforce Developers Should Focus on in Apex
    Ranked in Top Salesforce Blog by feedspot.com
    RSS Recent Stories
    • How to Connect Excel to Salesforce to Manage Your Data and Metadata February 9, 2025
    • Difference Between With Security and Without Security in Apex January 2, 2025
    • Top Reasons to Love Salesforce Trailhead: A Comprehensive Guide December 5, 2024
    • How to Utilize Apex Properties in Salesforce November 3, 2024
    • How to Choose Between SOQL and SOSL Queries July 31, 2024
    Archives
    Categories
    Tags
    apex (110) apex code best practice (8) apex rest (11) apex trigger best practices (4) architecture (22) Asynchronous apex (9) AWS (5) batch apex (9) batch processing (4) code optimization (8) custom metadata types (5) design principle (9) file upload (3) flow (14) future method (4) google (6) google api (4) integration (19) integration architecture (6) lighting (8) lightning (64) lightning-combobox (5) lightning-datatable (10) lightning component (29) Lightning web component (61) lwc (50) named credential (8) news (4) optimize apex code (4) Permission set (4) Queueable (9) rest api (23) S3 Server (4) salesforce (139) salesforce apex (46) salesforce api (4) salesforce api integration (5) Salesforce GraphQL API (3) Salesforce Interview Question (4) salesforce news (5) salesforce question (5) shopify api (3) solid (6) tooling api (5) Winter 20 (8)

    Get our newsletter

    Want the latest from our blog straight to your inbox? Chucks us your detail and get mail when new post is published.
    * indicates required

    Ranked #1 SALESFORCE DEVELOPER BLOG BY SALESFORCEBEN.COM
    Featured on Top Salesforce Developer Blog By ApexHours
    Recent Posts
    • Unlock the Power of Vibe Coding in Salesforce
    • How to Implement Dynamic Queueable Chaining in Salesforce Apex
    • How to Implement Basic Queueable Chaining in Salesforce Apex
    • How to Suppress PMD Warnings in Salesforce Apex
    • Top 10 PMD Issues Salesforce Developers Should Focus on in Apex
    Ranked in Top Salesforce Blog by feedspot.com
    RSS Recent Stories
    • How to Connect Excel to Salesforce to Manage Your Data and Metadata February 9, 2025
    • Difference Between With Security and Without Security in Apex January 2, 2025
    • Top Reasons to Love Salesforce Trailhead: A Comprehensive Guide December 5, 2024
    • How to Utilize Apex Properties in Salesforce November 3, 2024
    • How to Choose Between SOQL and SOSL Queries July 31, 2024
    Archives
    Categories
    Tags
    apex (110) apex code best practice (8) apex rest (11) apex trigger best practices (4) architecture (22) Asynchronous apex (9) AWS (5) batch apex (9) batch processing (4) code optimization (8) custom metadata types (5) design principle (9) file upload (3) flow (14) future method (4) google (6) google api (4) integration (19) integration architecture (6) lighting (8) lightning (64) lightning-combobox (5) lightning-datatable (10) lightning component (29) Lightning web component (61) lwc (50) named credential (8) news (4) optimize apex code (4) Permission set (4) Queueable (9) rest api (23) S3 Server (4) salesforce (139) salesforce apex (46) salesforce api (4) salesforce api integration (5) Salesforce GraphQL API (3) Salesforce Interview Question (4) salesforce news (5) salesforce question (5) shopify api (3) solid (6) tooling api (5) Winter 20 (8)

    Get our newsletter

    Want the latest from our blog straight to your inbox? Chucks us your detail and get mail when new post is published.
    * indicates required

    Facebook X (Twitter) Instagram Pinterest YouTube Tumblr LinkedIn Reddit Telegram
    © 2025 SalesforceCodex.com. Designed by Vagmine Cloud Solution.

    Type above and press Enter to search. Press Esc to cancel.

    Ad Blocker Enabled!
    Ad Blocker Enabled!
    Our website is made possible by displaying online advertisements to our visitors. Please support us by disabling your Ad Blocker.