<?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 Bharath Mulpuri on Medium]]></title>
        <description><![CDATA[Stories by Bharath Mulpuri on Medium]]></description>
        <link>https://medium.com/@bharathmulpuri?source=rss-9747a86b109c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*sEb0KiCrDi_ogqxs-KjlpQ.png</url>
            <title>Stories by Bharath Mulpuri on Medium</title>
            <link>https://medium.com/@bharathmulpuri?source=rss-9747a86b109c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 23:43:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bharathmulpuri/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[Vibe Coding for Salesforce: Real Test Data Without Leaking It]]></title>
            <link>https://medium.com/@bharathmulpuri/vibe-coding-for-salesforce-real-test-data-without-leaking-it-4a5d2a58fb2c?source=rss-9747a86b109c------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a5d2a58fb2c</guid>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[developer-sandbox]]></category>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[ai-tools]]></category>
            <category><![CDATA[sandbox]]></category>
            <dc:creator><![CDATA[Bharath Mulpuri]]></dc:creator>
            <pubDate>Tue, 03 Nov 2026 07:23:30 GMT</pubDate>
            <atom:updated>2026-11-03T07:23:30.054Z</atom:updated>
            <content:encoded><![CDATA[<h4>The AI writes the scripts. Real data reaches my dev org. And the AI never sees a single customer’s name.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pWyTVKRrEQL2V486MpK21Q.png" /><figcaption>Copy a small, connected and masked slice of real data into your dev org.</figcaption></figure><p>Every Salesforce developer knows this moment. You’ve built something you’re proud of: a new trigger, a flow, a screen your users have been asking for. You open your Developer sandbox to try it.</p><p>And there’s nothing there. No Accounts. No Contacts. Nothing that looks like the real business.</p><p>I’ve been in that spot more times than I can count, and it always plays out the same way. I create three test records by hand, everything passes, and the real problems wait quietly for UAT.</p><p>The usual answer is a paid seeding app. They work well, but they cost money, and not every team gets the budget for one.</p><p>So now I do it myself, for free. The scripts are boring glue code, which makes them a perfect job for vibe coding. The catch is keeping customer data away from the AI. Here’s how I do both.</p><h3>Four words before we start</h3><ul><li><strong>Full Copy sandbox:</strong> production’s setup and all of its data.</li><li><strong>Partial Copy sandbox:</strong> setup plus a sample of data, picked by a template.</li><li><strong>Developer org:</strong> a Developer sandbox or scratch org. Setup, no data.</li><li><strong>Vibe coding:</strong> you describe what you want in plain English, and AI writes code you review.</li></ul><h3>Why not just refresh?</h3><p>A Developer sandbox refresh brings your setup, not your records. A Full Copy refreshes about once a month. And you only need a few hundred connected records.</p><p><strong>200 is the number I start with.</strong> It’s exactly one trigger batch, so it’s enough to expose a query or DML statement inside a loop.</p><h3>Step 1: Tell the AI what you need</h3><p>Name the orgs, the objects, how many records, and what to mask. Then add three rules:</p><pre>Only run read queries against uat-full.<br>Never open or print the exported data files.<br>Show me every command before you run it.</pre><p><strong>The middle line is the one people miss.</strong> If the assistant opens Contact.json to &quot;check the export&quot;, real customer data lands in its context window. The AI can run commands once you approve them. It just never reads what they produce.</p><h3>Step 2: Export a connected slice</h3><p>Pick the safest source you can. A sandbox already masked with Salesforce Data Mask beats production. If you must use production, masking isn’t optional: privacy laws still apply in a dev org.</p><pre># Save the slice as a query file: 200 Accounts + children<br>cat &gt; account-slice.soql &lt;&lt;&#39;SOQL&#39;<br>SELECT Name, Industry,<br>  (SELECT FirstName, LastName, Email, Phone FROM Contacts),<br>  (SELECT Name, StageName, CloseDate, Amount<br>   FROM Opportunities)<br>FROM Account ORDER BY CreatedDate DESC LIMIT 200<br>SOQL</pre><pre>sf data export tree \<br>  --query account-slice.soql \<br>  --plan \<br>  --output-dir data \<br>  --target-org uat-full</pre><p>--plan writes one JSON file per object, plus a plan file. Contacts point to their Account by a reference name, not a Salesforce Id, so the links survive the move.</p><p>Tree commands are built for sets under about 3,000 records. Need more? See SFDMU near the end.</p><h3>Step 3: Mask the personal data</h3><p>This runs on your machine, between export and import. You run it, not the AI:</p><pre>// mask.js: fake but unique, so duplicate rules<br>// and unique fields don&#39;t reject the import<br>const fs = require(&#39;fs&#39;);<br>const masks = {<br>  &#39;data/Account.json&#39;: (r, i) =&gt; {<br>    r.Name = `Account ${i + 1}`;<br>  },<br>  &#39;data/Contact.json&#39;: (r, i) =&gt; {<br>    r.FirstName = &#39;Test&#39;;<br>    r.LastName = `Contact ${i + 1}`;<br>    r.Email = `contact${i + 1}@example.invalid`;<br>    r.Phone = &#39;555-0100&#39;;<br>  },<br>  // Deal names often contain the customer&#39;s name<br>  &#39;data/Opportunity.json&#39;: (r, i) =&gt; {<br>    r.Name = `Opportunity ${i + 1}`;<br>  },<br>};<br>for (const [file, mask] of Object.entries(masks)) {<br>  const data = JSON.parse(fs.readFileSync(file, &#39;utf8&#39;));<br>  data.records.forEach(mask);<br>  fs.writeFileSync(file, JSON.stringify(data, null, 2));<br>}</pre><p>Add an entry for every other field your security team calls confidential. Description fields are the usual suspects.</p><h3>Step 4: Import and count</h3><pre># The plan loads Accounts first, then children<br>sf data import tree \<br>  --plan data/Account-Contact-Opportunity-plan.json \<br>  --target-org my-dev</pre><pre># Should match the number of Contacts you exported<br>sf data query --target-org my-dev \<br>  --query &quot;SELECT COUNT() FROM Contact&quot;</pre><p>The plan file is named after your objects. Check the data folder.</p><p>The import fires your triggers, flows and validation rules, just like a user saving records. That’s good for testing, but it can stop the load. Read the error before you let the AI “fix” it by switching automation off.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tsoa1phil4DgYX1zMwzh5g.png" /><figcaption>The AI writes the scripts and never reads the data. You mask, review and run.</figcaption></figure><h3>Three mistakes to catch before you press Enter</h3><p>AI assistants tend to make the same few. Look for these in every command:</p><ul><li>Id, OwnerId or RecordTypeId in the query. Those Ids don&#39;t exist in your dev org.</li><li>A missing required field, so the import fails on the first record.</li><li>A missing or swapped --target-org. That&#39;s how test data lands in your Full Copy.</li></ul><h3>The prompt you can copy</h3><p>Paste this into any AI coding assistant:</p><pre>Help me copy test data between Salesforce orgs with<br>the sf CLI. Source alias: uat-full. Target: my-dev.</pre><pre>1. Write a SOQL file for 200 recent Accounts with<br>   their Contacts and Opportunities. No Id, OwnerId<br>   or RecordTypeId fields.<br>2. Export it with sf data export tree and --plan.<br>3. Write a Node script that replaces names, emails<br>   and phones in the exported JSON with fake,<br>   unique values. I will run it myself.<br>4. Import with sf data import tree --plan to my-dev.<br>5. Check imported counts match the exported counts.</pre><pre>Rules: only run read queries against uat-full.<br>Never open, print or summarize the data files.<br>Show each command and wait for my OK first.</pre><h3>It works for these scenarios</h3><ul><li>Reproducing a production bug.</li><li>Testing a trigger or flow at real volume before UAT does.</li><li>Demoing with believable records, not “Test Account 1”.</li><li>Onboarding a new developer on day one.</li></ul><h3>Other ways to do this</h3><p>This is the lightest option. Depending on your data size and budget, you might also look at:</p><ul><li><strong>SFDMU</strong>, a free plugin for the sf CLI, for bigger or repeatable loads across many related objects.</li><li><strong>Salesforce Data Mask</strong>, to mask a Full or Partial Copy at the source.</li><li><strong>Synthetic data</strong> with Snowfakery, when no real data is allowed at all.</li><li><strong>Paid seeding tools</strong> like Gearset, Prodly or Odaseva, when you want a UI and scheduled refreshes.</li></ul><p>An empty sandbox is where good work goes untested. Two hundred real, masked, connected records give it somewhere to land.</p><p>No paid app required.</p><p><em>If you’ve been stuck in an empty sandbox too, a clap helps other Salesforce developers find it. Want a follow-up on SFDMU? Tell me in the comments. Another one you might like: my post on building a </em><a href="https://medium.com/@bharathmulpuri/your-apex-code-will-fail-heres-one-retry-framework-for-every-scenario-43d8a0bb7738"><em>reusable Apex retry</em></a><em> framework.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a5d2a58fb2c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your Apex Code Will Fail. Here’s How to Make It Try Again.]]></title>
            <link>https://medium.com/@bharathmulpuri/your-apex-code-will-fail-heres-one-retry-framework-for-every-scenario-43d8a0bb7738?source=rss-9747a86b109c------2</link>
            <guid isPermaLink="false">https://medium.com/p/43d8a0bb7738</guid>
            <category><![CDATA[salesforce-development]]></category>
            <category><![CDATA[retry]]></category>
            <category><![CDATA[salesforce-apex]]></category>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[framework]]></category>
            <dc:creator><![CDATA[Bharath Mulpuri]]></dc:creator>
            <pubDate>Mon, 02 Nov 2026 07:50:41 GMT</pubDate>
            <atom:updated>2026-11-02T14:59:04.305Z</atom:updated>
            <content:encoded><![CDATA[<h3>A simple, reusable retry framework for Salesforce, explained so every developer can use it.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YtTrEQvn657FUOtnMT-45Q.png" /><figcaption>One retry framework for row locks, callouts, Platform Events and Batch Apex.</figcaption></figure><p>It was 4:47 on a Friday when a sales ops manager pinged me. “About 300 leads didn’t convert last night. But the job says it ran fine.”</p><p>She was right. It had.</p><p>Two processes had tried to update the same Account at the same moment, and one of them got locked out. An old try/catch wrote the error to a debug log and carried on as if nothing happened. No retry. No alert. Fixing it took forty minutes. Finding it took a day and a half.</p><p>After that weekend I built one small retry framework, and I’ve reused it ever since. Here’s how it works.</p><h3>Four words before we start</h3><ul><li><strong>Transient error:</strong> a temporary problem. Try again and it usually works, like a record locked by someone else.</li><li><strong>Permanent error:</strong> trying again won’t help, like a missing required field.</li><li><strong>Queueable:</strong> Apex that runs in the background, after the user’s click is done.</li><li><strong>Finalizer:</strong> code Salesforce runs after a Queueable finishes, even if the Queueable crashed.</li></ul><h3>Step 1: Only retry what’s worth retrying</h3><p>Most retry code retries everything. But a missing field fails the same way on the third try, so you’ve only burned limits and buried the real bug.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mr7ITGGlDy-CVYj3y-SknQ.png" /><figcaption>Transient errors get retried. Permanent errors get surfaced.</figcaption></figure><p>So I keep that decision in one method, and the whole org uses it:</p><pre>public static Boolean isTransient(Exception error) {<br><br>    // Another process had the record locked<br>    if (error instanceof DmlException) {<br>        DmlException dmlError = (DmlException) error;<br>        return dmlError.getDmlType(0)<br>            == StatusCode.UNABLE_TO_LOCK_ROW;<br>    }<br><br>    // The external system was too slow to answer<br>    if (error instanceof CalloutException) {<br>        return error.getMessage().contains(&#39;timed out&#39;);<br>    }<br><br>    // Bad data or a code bug: retrying won&#39;t fix it<br>    return false;<br>}</pre><h3>Step 2: Describe the work, not the retry</h3><p>Anything you want retried implements one small interface. You write what should happen. The framework works out when to try again.</p><pre>public interface RetryableWork {<br>    void execute(RetryContext ctx); // do the work once<br>    String key();                   // a unique name for it<br>    Type workType();                // lets it be replayed<br>}</pre><p>Here’s a complete example. It sends an order to an ERP system:</p><pre>public class SendOrderToErp implements RetryableWork {<br><br>    public Id orderId;<br><br>    public SendOrderToErp() {}           // needed for replay<br>    public SendOrderToErp(Id orderId) {<br>        this.orderId = orderId;<br>    }<br><br>    public void execute(RetryContext ctx) {<br>        HttpRequest req = new HttpRequest();<br>        req.setEndpoint(&#39;callout:ERP_API/orders/&#39; + orderId);<br>        req.setMethod(&#39;POST&#39;);<br><br>        HttpResponse res = new Http().send(req);<br><br>        if (res.getStatusCode() == 503) {   // server busy<br>            ctx.retry(&#39;ERP is busy&#39;);       // try again later<br>        }<br>    }<br><br>    public String key()    { return &#39;ERP-ORDER-&#39; + orderId; }<br>    public Type workType() { return SendOrderToErp.class; }<br>}</pre><p>Notice that ctx.retry() asks for another attempt without throwing an error. An unhandled error rolls back everything the transaction saved, so this keeps the work that already succeeded.</p><h3>Step 3: Pick how it runs</h3><p>It’s one line, and you have three choices:</p><pre>// Try now, up to 3 times. Still failing? Go to background.<br>Retry.now(work, &#39;RowLock&#39;);<br><br>// Run in the background with automatic retries<br>Retry.async(new SendOrderToErp(order.Id), &#39;ERP&#39;);<br><br>// Run later, after a vendor&#39;s maintenance window<br>Retry.at(work, &#39;ERP&#39;, Datetime.now().addHours(4));</pre><p>&#39;RowLock&#39; and &#39;ERP&#39; are retry policies. A policy sets how many attempts are allowed and how long to wait between them. Policies live in Custom Metadata, so an admin can tune them without a deployment.</p><h3>Step 4: Let the Finalizer decide what’s next</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mTD-YhQO-4mGsasgBivbfw.png" /><figcaption>Your code describes the work. The engine decides when to try again.</figcaption></figure><p>Your work runs in a Queueable. When it ends, the Finalizer checks what happened and picks the next move. Simplified:</p><pre>public void execute(FinalizerContext ctx) {<br><br>    // It worked. Nothing to do.<br>    if (ctx.getResult() == ParentJobResult.SUCCESS) {<br>        return;<br>    }<br><br>    Exception error = ctx.getException();<br><br>    // Temporary problem with tries left: wait, then retry<br>    if (RetryClassifier.isTransient(error)<br>            &amp;&amp; job.hasTriesLeft()) {<br>        System.enqueueJob(job.nextAttempt(), job.waitMinutes());<br>        return;<br>    }<br><br>    // Out of luck: save it so a person can replay it later<br>    RetryStore.deadLetter(job, error);<br>}</pre><p>Each wait is about double the last one: 1 minute, then 2, then 4. Work that runs out of tries is saved as a “dead letter” record. Once someone fixes the cause, they click Replay and it runs again.</p><p>I learned these three rules the hard way:</p><ol><li><strong>Attach the Finalizer on the first line of your Queueable.</strong> If anything fails before that line, nothing gets retried.</li><li>Keep the attempt count on the job, not in a static variable. Statics reset on every attempt, so &quot;three tries&quot; becomes forever.</li><li>Never catch an error and ignore it. The Finalizer will think everything went fine.</li></ol><h3>It covers the scenarios you actually hit</h3><ul><li><strong>A save runs into a locked record:</strong> Retry.now() tries again right away, then moves the work to the background.</li><li><strong>An external system is slow or down:</strong> waits get longer between tries, and calls pause completely while the system is down.</li><li><strong>A Platform Event fails:</strong> it gets a few retries, then it’s set aside so one bad message can’t block the rest.</li><li><strong>A Batch Apex chunk fails:</strong> only that chunk runs again.</li><li><strong>A record you need doesn’t exist yet:</strong> throw Retry.TransientException and it&#39;s retried later.</li></ul><h3>Before you add a retry, ask one question</h3><p>What happens if this runs twice?</p><p>Sometimes the first attempt worked and only the response got lost, so a retry creates a duplicate. Use upsert with an External ID instead of insert, and send a unique key with every callout.</p><p>Your code will fail. Row locks happen and APIs go down. What matters is whether it fails forward, into another attempt or into a record someone can replay in minutes.</p><p>That Friday would have been a quiet one.</p><p><em>If this helped, a clap helps other Salesforce developers find it. I’d love to hear your own retry horror story in the comments.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43d8a0bb7738" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>