Forge Application License Verification in Scheduled Triggers

We have developed a forge application for Jira and Confluence, which includes a user interface and a scheduled trigger. Some users have been using our application on a trial basis, but their trial periods have expired. Despite this, the scheduled triggers for those users are still activating and executing business logic. How can we modify the scheduled trigger to verify and enforce license validity?

Hi Jay,

We recommend you check the license at the start of your schedule trigger; validate if active, if not exit, otherwise continue with your business logic. Details can be found here: https://developer.atlassian.com/platform/forge/function-reference/arguments/

We have some improvements on this in our long term backlog relating to setting flags in the manifest to disable this.

Let me know how you go.

Cheers
Ben

Hi Benny , Thank you for your suggestion! I tried implementing the solution as you described, but I couldn’t find the license property under the context object. I’ve attached the relevant code from our dummy app for reference. Could you please help me identify where I might have gone wrong? , We deployed our dummy app as a production release and have attached the logs for your reference (note - forge CLI version = 10.4.0)



Hey @JayPerera,

You’ll need to utilise the AppContext to attain the license information.

Could you try something like below?

import { getAppContext } from "@forge/api";

const { appAri, appVersion, environmentAri, environmentType, invocationId, installationAri, moduleKey, license } = getAppContext();
console.log(JSON.stringify(license));
//{"isActive":true,"billingPeriod":"MONTHLY","ccpEntitlementId":"NULL","ccpEntitlementSlug":"NULL","isEvaluation":"NULL","subscriptionEndDate":"NULL","supportEntitlementNumber":"NULL","trialEndDate":"NULL","type":"commercial"}

If you’re testing this in development, you’ll also need to ensure that you set a license state, otherwise this won’t be available in the context.

Cheers,
Sean

1 Like

Hi SeanBoruke ,

Thank you for the solution and it is working

cheers

2 Likes