add a custom fields validator using jira expression

Koceila CHERGUI September 6, 2021

Hello,
I'm working on a projet where I have a screen with custom fields on it, I would like to use a validator using jira expression.

I read the documentation but I didn't understand how to use it on a custom field.

3 answers

1 accepted

2 votes
Answer accepted
Oliver Siebenmarck _Polymetis Apps_
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.
September 6, 2021

Hi @Koceila CHERGUI ,

Welcome to the community! 

You will need two things to use Jira Expressions in a Validator in Jira Cloud. First (like @Fabian Lim correctly mentioned) , you need a workflow app that supports Jira Expressions. In my biased opinion Cloud Workflows is the easiest option, although there are also other options in the marketplace. 

Second, you need to know the ID of your custom field. And that's it. You can now use an expression like this:

issue.customfield_10019 != "foo"

To ensure that your custom field is not set to "foo". 

Of course, Jira Expressions are pretty powerful but can seem a bit daunting at the start. If you just want to play around with them before committing any buying an app, there's a free app called Expression Tester to let you do just that.

Hope that helps,
 Oliver

Full disclosure: I work for the vendor who created Cloud Workflows and the Expression Tester. I'm also quite a big fan of Jira Expressions. Let me know if you need any help getting started.

Koceila CHERGUI September 7, 2021

I would like to thank you for your reply.
I understand more about it.

 

Koceila.

0 votes
Nikita Rao May 24, 2023

Hey guys, 

I am in a similar situation. My use case is I want to validate on a custom field where if the custom field has an option selected from the dropdown say "x" then I want the user to fill out a different field on the "close issue screen" 

I used the Jira expression JWT to say "issue?.customfield_10152?.value == "x" then on close show an error saying "Please fill out xyz field before closing" . But this somehow doesn't seem to work. Any ideas? 

Thorsten Letschert _Decadis AG_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
May 24, 2023

Hi @Nikita Rao ,

in this case, you probably need a conditional operator (see https://apps.decadis.net/pages/viewpage.action?pageId=38569652#expand-Examplesofusingtheconditionaloperator) like

issue?.customfield_10152?.value == "x" ? issue?.customfield_##### != null : true

replacing ###### with the custom field ID of your xyz field.

With this expression, the xyz field must not be empty if your 10152 field equals "x". Otherwißse the condition is true by default.

Please let me know if that solves your request.

Cheers,
Thorsten

0 votes
Fabian Lim
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 6, 2021

Hi @Koceila CHERGUI,

Take a look at this tutorial on transition screens which describes how you can add validators end to end. Link: https://www.youtube.com/watch?v=RIKYX-z4meM

You may have to purchase a certain plugin such as JSU to have the expression validator: https://beecom-products.atlassian.net/wiki/spaces/JSU/pages/25680565/Regular+Expression+Check+Validator

I hope this helps 

Koceila CHERGUI September 7, 2021

Thank you 

Suggest an answer

Log in or Sign up to answer