Custom UI bridge
Custom UI Jira bridge

Rate this page:

workflowRules (EAP)

The workflowRules object is available as an Early Access Program (EAP). Be aware that future changes may break your apps.

If your app uses the jira:workflowValidator module with custom UI, you can use the workflowRules object to pass additional configuration data. This data will be available when the Jira expression or Forge function validator is evaluated.

onConfigure

The onConfigure method enables you to pass a callback function that should return a stringified JSON value based on your input elements. This will be saved as validator configuration. When evaluating the validator, this configuration will be available under the config context variable.

The onConfigure callback is invoked in two cases:

  • when the user clicks the Add button on the create view displayed when adding a new validator
  • when the user clicks the Update button on the edit view displayed when editing an existing validator

If you want to prevent users from submitting the form and don't want to save the current configuration, return an undefined value from this callback.

Function signature

1
2
type OnConfigureResponse = string;
type OnConfigureFn = () => Promise<OnConfigureResponse> | OnConfigureResponse;

function onConfigure(onConfigureFn: OnConfigureFn): Promise<void>;

Example

1
2
import { workflowRules } from '@forge/jira-bridge';

// When the configuration is saved, this method is called. Return the configuration based on your input elements.
const onConfigureFn = async () => {
    const config = {
        "key": "val"
    };

    // If you want to skip form submission, return undefined value.
    /*
    const isFormDataValid = await validateForm(config);
    if (!isFormDataValid) {
      return undefined;
    }
    */

    return JSON.stringify(config); // The string returned here will be available under the `config` context variable.
}

try {
    workflowRules.onConfigure(onConfigureFn);
} catch (e) {
    // Handle the error.
}

The saved configuration will appear under the extension.validatorConfig key in the context object returned from the getContext API in the custom UI bridge.

1
2
import { view } from '@forge/bridge';

const context = await view.getContext();
const savedValidatorConfig = context.extension.validatorConfig;

Rate this page: