November 8, 2022

Announcing Support for Apex in Harness Feature Flags

Table of Contents

Harness now supports Apex in its Feature Flags, enabling Salesforce developers to leverage advanced feature management. The new Apex SDK streamlines the integration process, allowing teams to deliver updates faster and with greater confidence. Check out the tutorial for setup and deployment steps.

Apex is an increasingly popular language used for building software based on the Salesforce platform. Salesforce apps, like all other apps, can benefit from feature flags. 

Today, we are announcing that Harness Feature Flags, our feature management platform, now has an open source Apex SDK. We are excited to power a new generation of Salesforce app development, enhancing the user experience by giving teams the ability to iterate and ship business-critical applications more quickly and safely.

Salesforce apps are the lifeblood of many organizations. It’s important that they have the same access to feature management so that they can reap the same benefits and deliver customer value. Now, these teams can deliver software faster, more safely, and innovate more by making use of the Apex SDK for Harness Feature Flags.

Getting Started with Apex for Feature Flags

To start using Apex for your own feature flags, check out the Apex SDK Reference. The guide there will walk you through how to get a hold of the SDK, initialize, and create your first feature flag.

Harness Feature Flag users can expect the same feature support and performance that they’re used to from other open source Harness Feature Flag SDKs. If you’re already familiar with any of the other SDKs supported, the same patterns and use cases apply. And if not, then the docs will guide you through it.

Using our Apex SDK will be straightforward if you are used to working with Apex. To start, just install the SDK:

$> sfdx force:source:deploy --targetusername='YOUR TARGET ORG' --sourcepath='force-app'

From there, you will initialize the SDK and configure your target model (if you’re not familiar with targets, read more here):

// Set flagKey to the feature flag key you want to evaluate.
String flag = 'harnessappdemodarkmode';
// set cache Namespace and Partition
FFOrgCache cache = new FFOrgCache('local', 'basic');
FFConfig config = new FFConfig.builder().cache(cache).build(); 
// Set up the target properties.
FFTarget target = FFTarget.builder().identifier('Harness').name('Harness').build();
FFClient client = new FFClient('Your SDK Key', target, config);

From there, simply implement your flags.

// Bool evaluation
Boolean value = client.evaluate(flag, false);
System.debug('Feature flag ' + flag + ' is '+ value + ' for this user');

Getting Your First Feature Flag Into Production

Using the Apex SDK in your code is only half the equation. While it’s critical to ensure the SDK is working as expected, wrapping your features or changes in a flag inside your codebase is the first of two steps you need to take to have a fully functional feature flag.

The second step, if you haven’t done so already, is to head over to your Harness project and create a flag in the Harness app. Once both pieces are done, you’ll be ready to roll out your feature flag. If you need additional help, you can either follow the in-app wizard, or you can check out the Getting Started documentation.

Ready to get started? Start your free trial today!

Happy flagging!

You might also like
No items found.
Gitness
Code Repository
Software Supply Chain Assurance
Infrastructure as Code Management
AIDA
Continuous Error Tracking
Internal Developer Portal
Software Engineering Insights
Platform
Cloud Cost Management
Chaos Engineering
Continuous Delivery & GitOps
Security Testing Orchestration
Service Reliability Management
Feature Flags
Continuous Integration