Product
|
Cloud costs
|
released
November 8, 2022
|
3
min read
|

Announcing Support for Apex in Harness Feature Flags

Updated
9/15/2023

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!

Sign up now

Sign up for our free plan, start building and deploying with Harness, take your software delivery to the next level.

Get a demo

Sign up for a free 14 day trial and take your software development to the next level

Documentation

Learn intelligent software delivery at your own pace. Step-by-step tutorials, videos, and reference docs to help you deliver customer happiness.

Case studies

Learn intelligent software delivery at your own pace. Step-by-step tutorials, videos, and reference docs to help you deliver customer happiness.

We want to hear from you

Enjoyed reading this blog post or have questions or feedback?
Share your thoughts by creating a new topic in the Harness community forum.

Sign up for our monthly newsletter

Subscribe to our newsletter to receive the latest Harness content in your inbox every month.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Feature Flags