Forums

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

Workflow If then validator

Yves MOUAFO July 15, 2024

Hello,

I have the two  following custom fields:

- CF1: checkbox (Values: "Yes", "No") 

- CF2: URL Field
I would like to add a validator to the workflow  as follows:
If CF1="Yes", then the field CF2 is mandatory to transit from state A to state B in the workflow.

Please is there any means to do this with Jira?

Kind regards

2 answers

2 votes
Maciej Dudziak _Forgappify_
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.
July 15, 2024

Hi @Yves MOUAFO

If you are open to using apps, consider using a Jira expression-based validator. There are several options available on the marketplace.

We've developed the Jira Expression Validator as part of the free  Workflow Building Blocks for Jira  app. The Jira expression for your case will be similar to the following:

issue.customfield_xxxxx.value == "Yes" 
? issue.customfield_yyyyy != null
: true

You need to change the ID of the custom field to a valid one. In the editor, after 'issue.', start typing the name of the field, and you will get suggestions with the correct value.

I hope it will help.

Cheers

 

Yves MOUAFO July 15, 2024

Thank you for your help. I have tried this solution but there is a mistake in the Jira expression. See the screenshot below 

 Capture d’écran du 2024-07-15 16-41-05.png

Maciej Dudziak _Forgappify_
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.
July 15, 2024

Validation message must be a string, please surround it with ""

Yves MOUAFO July 16, 2024

OK thank you, it works now!

Maciej Dudziak _Forgappify_
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.
February 5, 2025

Hi @Yves MOUAFO 

Hope you're doing well! Our journey to simplifying Jira Expressions has brought us to the 'Ultimate Validator' (now in Beta). It lets you tap into most of the power of Jira Expressions—without writing a single line of code—through a simple UI. Just wanted to share this with you—hope you find it useful! Here’s how your case of a conditionally required field looks in the UI

Conditional_require_780.gif

Cheers

0 votes
Dick
Community Champion
July 15, 2024

You can use Automation for Jira.

Trigger would be the transition of the issue. We would check if the status transfer is prohibited by your prerequisites. If so, we would restore the ticket to the original status. 

So for this, you would need the history of the status field of the ticket to be able to get the original status back if the mandatory item for the transition is empty. Best to store it in a variable {{originalStatus}}

Checking both prerequisite related entries is possible using the conditional blocks. 

However, your fields are custom fields. these have a somewhat different system name that should be used to address them in the conditional statements:

it would not be cf1 but cf[xyz]. where xyz is a 5 digit number.
You can look these up by using the field in an advanced search issue command and look at the syntax help that pops up while you write the field name. In each Jira instance these numbers are different, so you need to look them up in your instance.

The conditional line in the Jira Automation would look like:

if cf[12345] = 'yes' then...

 

Yves MOUAFO July 16, 2024

OK thank you for your help

Suggest an answer

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

Atlassian Community Events