How to use custom fields in connect's jiraWorkflowValidators module

Javier Perez
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 28, 2021

Use case

I'm trying to do a connect workflow validator following this documentation Custom fields are available according to this other documentation.

Issue

My app installation fails (error msg: "An error occurred during installation. Contact the app vendor for support.") when using this expression in the app descriptor:

"expression": "issue.resolution.name == 'Done' && issue.customfield_10077 != null"

 Questions

  • Can custom fields be used in expressions in the jiraWorkflowValidators module
  • If so, which one is the right syntax to test for a custom field not to be empty

1 answer

1 accepted

0 votes
Answer accepted
Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 29, 2021

Hi Javier - are you developing your own Jira application (add-on/plug-in?)? Cool!

One of my favorite apps for testing Jira Expressions is Jodocus's Expression Tester.

You could use it to validate your expression. The correct syntax for determining if a field is "empty" is: !!issue.customfield_10077

So I might try:

"issue.resolution.name == 'Done' && !!issue.customfield_10077"

Let us know how it goes.

By the way, if you're not trying to build your own application that includes a workflow validator, then to use Jira Expressions for that, you'll need to use an add-on:

Javier Perez
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 29, 2021

Thanks Darryl for your tips!

I simplified my expression to focus in the custom field. I installed Expression Tester and tested my expression syntax, which went through, see below.

My installation is however still throwing error.

This is the jiraWorkflowValidators entry in my descriptor

"jiraWorkflowValidators": [{
"key": "workflow-validator-edf",
"name": {
"value": "Early Detection Phase mandatory validation"
},
"description": {
"value": "Early Detection Phase fields should be mandatory when resolution is fixed"
},
"errorMessage": {
"expression": "'Early Detection Phase can not be empty when Resolution is fixed'"
},
"expression": "!issue.customfield_10077"
}]

If I change expression to "expression": "issue.resolution.name == 'Done'"  as below the app installs (and runs) correctly

"jiraWorkflowValidators": [{
"key": "workflow-validator-edf",
"name": {
"value": "Early Detection Phase mandatory validation"
},
"description": {
"value": "Early Detection Phase fields should be mandatory when resolution is fixed"
},
"errorMessage": {
"expression": "'Early Detection Phase can not be empty when Resolution is fixed'"
},
"expression": "issue.resolution.name == 'Done'"
}]

Any suggestions....?

Thanks!

Expression Tester:

evaluator.png

Installation error

installation.png

Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 1, 2021

Alas, unfortunately development of add-ons is beyond my experience. You might try registering and asking in the Developer Community. This forum is specifically devoted to Jira Cloud:

https://community.developer.atlassian.com/c/jira/jira-cloud/7

Good luck!

Javier Perez
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 1, 2021

I didn't now about the forum you mention.Thanks Darryl!

Javier Perez
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 15, 2021

Atlassian support provided me with the logs of my app installation. It was not very clear what the problem was, but entries made reference to uninstalling the app because of an issue in another module I had in the same descriptor, a module that we've had deployed for months. After separating jiraWorkflowValidators into another descriptor if worked well with the original expression

"expression": "issue.resolution.name == 'Done' && issue.customfield_10077 != null"

go figure.

 

@Darryl Lee , thanks again for your help

Suggest an answer

Log in or Sign up to answer