Rate this page:
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
or jira:workflowCondition
module
with custom UI, you can use the workflowRules
object to pass additional configuration data. This data will be
available when evaluating the Jira expression.
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 workflow module configuration. When evaluating the validator or condition,
this configuration will be available under the config
context variable.
The onConfigure
callback is invoked in two cases:
Add
button on the create
view displayed when adding a new validator or conditionUpdate
button on the edit
view displayed when editing an existing validator or conditionIf 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.
1 2type OnConfigureResponse = string; type OnConfigureFn = () => Promise<OnConfigureResponse> | OnConfigureResponse; function onConfigure(onConfigureFn: OnConfigureFn): Promise<void>;
1 2import { 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. } // calling onConfigure from async function try { await workflowRules.onConfigure(onConfigureFn); } catch (e) { // Handle the error. } // calling onConfigure from non-async function workflowRules .onConfigure(onConfigureFn) .catch(e => { // Handle the error. });
The saved configuration will appear under the extension.validatorConfig
or extension.conditionConfig
key in the
context object returned from the getContext API in the custom UI
bridge.
1 2import { view } from '@forge/bridge'; const context = await view.getContext(); const savedValidatorConfig = context.extension.validatorConfig; const savedConditionConfig = context.extension.conditionConfig;
Rate this page: