Skip to main content

Hi everyone,

We recently built a custom Sales Force application in a sandbox environment that handles data sharing with a third-party API. The solution involves custom screens, automations, and data sync back and forth with the external system. 

 

Now, our client wants us to do the exact same thing for another third-party API integration, using the same overall structure and business workflow.

What is the best way to approach this?

  1. Should we replicate/clone the existing application inside the same sandbox/org and adapt it for the second API?
  2. Or is it better practice to package and deploy the build into a fresh, separate environment for the new integration?

If you have done something similar, what would you recommend, and what are the key things or common challenges we should keep in mind before starting?

Thanks in advance! 

 

#Salesforce Developer  #Salesforce  #Integration  #Trailhead

1 resposta
  1. 25 de set., 10:21

    Hi Cloud Crafter, 

     

    Short answer: don't clone the app — generalize it. Build the integration logic once as a reusable, config-driven layer, then add the second API as a new configuration, not a new copy of the app. 

     

    Why cloning is the wrong move: 

    - Two copies of the same objects/flows/Apex means every future bug fix, security patch, or workflow change has to be done twice, and they will drift out of sync within months. 

    - It roughly doubles your metadata footprint in the same org for no real functional benefit, since both integrations share the same overall structure anyway. 

    - It makes testing, permissions, and reporting messier — you'll end up needing to explain to users/admins why there are two near-identical apps doing conceptually the same thing. 

     

    Recommended approach: 

     

    1. Extract what's actually integration-specific into configuration, not code/metadata. Things like endpoint URLs, auth credentials, field mappings, and payload structure should live in Custom Metadata Types or Named Credentials/External Credentials — not hardcoded per-integration Apex classes or per-integration Flows. 

     

    2. Keep one set of core objects, screens, and automations, parameterized by an "Integration Type" or "Source System" field/record, so the same Flow/Apex logic branches or reads config rather than being duplicated. 

     

    3. Use Named Credentials (or External Credentials with Named Principals) per third-party API. This is the standard Salesforce pattern for "same integration pattern, multiple external systems" — one generic Apex HTTP callout class, driven by whichever Named Credential/config record applies. 

     

    4. If the two integrations genuinely have very different data models or business logic (not just a different endpoint), that's the signal to build a second app rather than force everything into one config-driven framework — don't over-engineer for reuse that doesn't fit. 

     

    On sandbox vs. new org: stay in the same org/sandbox unless there's a hard business reason to separate (e.g., different client legal entities, data residency requirements, or genuinely unrelated user bases). A second full org means duplicating users, licenses, security model, and ongoing maintenance — that's a much bigger cost than it sounds, and it's rarely justified just because it's "a new integration." 

     

    Common pitfalls to watch for: 

    - Hardcoded field mappings buried in Apex instead of Custom Metadata — this is the #1 thing that makes the "just clone it" temptation so strong, and the #1 thing that makes maintenance painful later 

    - Bulkification/governor limits — if the second integration runs concurrently with the first, make sure shared triggers/flows are bulk-safe, since now two integrations' worth of volume can hit the same automation 

    - Error handling and retry logic tied to one specific API's response format — generalize this early, or you'll end up with API-specific error handling scattered everywhere

0/9000