No items found.

Announcing Support for Apex in Harness Feature Flags

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

Published on
11/8/22

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 now has an open source Apex SDK. We are excited to power a new generation of Salesforce app development, giving users 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 the 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!

The Modern Software Delivery Platform™

Loved by Developers, Trusted by Businesses
Get Started

Need more info? Contact Sales