Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Add Jira Expressions in Validators / Conditions using Forge

Veeresh G S (MicroGenisis TechSoft)
Atlassian Partner
June 5, 2024

I am able to achieve individual Jira expressions in validators and conditions using Forge in my manifest.yml file. However, I need to override these Jira expressions using a custom UI. In the UI, if I input a Jira expression, I want Forge to read and validate it. How can I achieve this?

App.js:

useEffect(() => {
view.getContext().then((ctx) => {
let config = {
searchString: '',
};
try {
config = JSON.parse(ctx.extension.validatorConfig);
} catch {
// noop
}

setExtensionData(ctx.extension);
setValidatorConfig(config);
});
}, []);

useEffect(() => {
workflowRules
.onConfigure(async () => JSON.stringify(validatorConfig))
.catch((err) => {
console.error(`Unable to add workflow rule configuration callback: ${err}`);
});
}, [validatorConfig]);

if (!extensionData) {
return <p>Validator is loading.</p>;
}

if (extensionData.entryPoint === 'view') {
// display validator configuration
return <p>Summary field must contain text: "{validatorConfig.searchString}"</p>;
}
// create/edit view below
const handleOnChange = (evt) => {
setValidatorConfig({
searchString: evt.target.value,
});
};

Manifest.yml:

modules:
jira:workflowValidator:
- key: jira-workflow-example-workflow-validator-custom-ui-expression
name: jira-workflow
description: A Jira workflow validator example using expression, custom UI, and
validator configuration.
expression: issue.assignee != null
errorMessage:
expression: "'The transition failed because issue summary doesn\\'t include \"'
+ config['searchString'] + '\".'"
view:
resource: custom-ui-expression
edit:
resource: custom-ui-expression
create:
resource: custom-ui-expression
trigger:
- key: jira-workflow-failed-expression-trigger
function: listen
events:
- avi:jira:failed:expression
function:
- key: listen
handler: index.listen
resources:
- key: custom-ui-expression
path: static/custom-ui-expression/build

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events