DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Strategic Roadmap for Modernizing Digital Operations: Transitioning from Legacy Development Models to Agile-Driven Integrated Frameworks
  • Instant Integrations With API and Logic Automation
  • Ionic App Development Over Other Frameworks: Is It Hyped?
  • WebDriverIO Integration With Cucumber

Trending

  • Recurrent Workflows With Cloud Native Dapr Jobs
  • Hybrid Cloud vs Multi-Cloud: Choosing the Right Strategy for AI Scalability and Security
  • My LLM Journey as a Software Engineer Exploring a New Domain
  • Solid Testing Strategies for Salesforce Releases
  1. DZone
  2. Coding
  3. Frameworks
  4. Feature Flag Framework in Salesforce Using LaunchDarkly

Feature Flag Framework in Salesforce Using LaunchDarkly

A Salesforce feature flag system using custom permissions and LaunchDarkly enables controlled rollouts, rapid reversals, and seamless feature management.

By 
Ronith Pingili user avatar
Ronith Pingili
·
Apr. 16, 25 · Analysis
Likes (1)
Comment
Save
Tweet
Share
3.6K Views

Join the DZone community and get the full member experience.

Join For Free

Releasing new features in a Salesforce environment can sometimes feel like walking a tightrope; one misstep can take down mission-critical processes. That’s why feature flagging has emerged as a powerful strategy. Instead of deploying features to everyone all at once, you introduce them incrementally, fine-tuning your approach along the way.

In this article, I’ll share how I built a feature flag framework using custom permissions, permission sets, and an integration with LaunchDarkly. This setup has helped my team safely roll out new Salesforce functionality while maintaining complete control over who sees what and when.

The Pain Point

When multiple teams collaborate in a single Salesforce org, rolling out new features can quickly spiral into chaos, especially if you’re dealing with multiple deployment windows or a large user base. A typical scenario might look like this:

  • Multiple new functionalities are ready to go live around the same time.
  • You want certain features to reach a small percentage of users for an initial pilot.
  • Another set of functionalities needs to be turned on for just a subset of roles or profiles.

Relying on standard Salesforce profiles and permission sets alone won’t always cut it for a graceful, phased rollout. You need something more dynamic.

Why Feature Flags?

Feature flags allow you to turn functionality on or off without the hassle of multiple code deployments. This approach is particularly useful when you:

  • Want to test new features with small user groups (e.g., 10% of the org).
  • Need to disable a feature in seconds if it causes issues.
  • Don’t want to deploy another package or set of changes just to tweak permissions.

The Core Architecture

1. Custom Permissions

  • Each new feature is paired with a custom permission in Salesforce (e.g., FEAT_NewFeatureXYZ).
  • Custom permissions are easy to reference in Apex, Lightning Web Components, and Flow, making them a great backbone for feature toggles.

2. Permission Sets

  • Create a dedicated permission set for each feature and attach the relevant custom permission.
  • Assigning this permission set to a user effectively flags the feature on for that user, and removing it flags the feature off.

3. LaunchDarkly Integration + Custom Object

  • Whenever a new flag is created in LaunchDarkly, the integration automatically creates (or updates) a custom object record in Salesforce that includes:
    • The LaunchDarkly flag details (e.g., name, environment).
    • The rollout percentage (e.g., 50%, 100%) or status (enabled/disabled).
  • A batch Apex job periodically runs after record, create, or update and handles permission set assignments or removals.

How It All Works

1. New Flag Creation in LaunchDarkly

  • Let’s say you create a flag called FEAT_NewDashboard in LaunchDarkly, configured for a 50% rollout.
  • The integration fires, automatically creating or updating a custom object record in Salesforce that says, in essence:
    "Flag: FEAT_NewDashboard, Rollout: 50%.”

2. Salesforce Batch Assignment

  • A batch job reads this record and assigns the permission set with the flag name to 50% of the relevant user base.
    • If the record states a 100% rollout, the batch job assigns it to all users.
    • If it’s disabled or 0%, the batch job removes the permission set from everyone.

3. User Checks

  • In Apex, Flow, Lightning Web Components code checks if a user has the custom permission (via the assigned permission set).
  • If FEAT_NewDashboard is assigned, the user sees the new dashboard. Otherwise, it remains hidden.

4. Ongoing Updates

  • If you later decide to increase the rollout to 75% in LaunchDarkly, the Salesforce custom object will be updated accordingly.
  • The batch job runs after record update, it sees the updated 75% rollout and assigns the permission set to an additional 25% of users, bringing the total to 75%.
  • If issues occur, toggling the LaunchDarkly flag to “off” will change the salesforce record to disabled. The next batch run removes the permission set from all users, effectively shutting off the feature.

5. Gradual Rollouts in Action

  • Want to start small? Set the rollout to 5% in LaunchDarkly. The batch job assigns the permission set to 5% of users.
  • If everything goes well, crank it up to 50%, 75% and eventually 100%. Should something go wrong, you can switch the LaunchDarkly flag to “disabled” and the subsequent batch job revokes the permission set, no code redeployment or manual user-by-user removal needed.

Why This Approach Rocks

  • Automated control: Once you set up the custom object and integration, developers can manage rollout percentages purely in LaunchDarkly.
  • Real-time rollouts: Integration jobs run at your chosen interval, so changes in LaunchDarkly reflect in Salesforce relatively quickly.
  • Fewer deployment headaches: No need to push new code when toggling a feature on or off everything happens through data and permission sets.
  • Safe testing: Roll out to a subset of users, gather feedback, and gradually expand. If something breaks, turn it off instantly via the LaunchDarkly flag.

Final Thoughts

Feature flagging in Salesforce doesn’t have to be complicated. You can transform how you roll out changes by harnessing custom permissions, permission sets, and a well-structured integration with LaunchDarkly (or any similar tool). This framework offers flexibility and quick reaction times, a big win for teams that need to innovate without jeopardizing stability.

feature flag Framework Integration

Opinions expressed by DZone contributors are their own.

Related

  • Strategic Roadmap for Modernizing Digital Operations: Transitioning from Legacy Development Models to Agile-Driven Integrated Frameworks
  • Instant Integrations With API and Logic Automation
  • Ionic App Development Over Other Frameworks: Is It Hyped?
  • WebDriverIO Integration With Cucumber

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!