Forums

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

Implementing a condition to prevent a status transition to done

Thies Uhlenbruch
Contributor
July 31, 2023

Hey,

I need a condition in my workflow to prevent issue to be transitioned to done if 2 customfields has specific value.

customfield_10457 = "Nein" and customfield_10458 != EMPTY

We are using Scriptrunner and I guess I have to use this for this use case (Script Condition with Jira Expression) but I have no idea to start with :-)

I'm glad to get any help.

Cheers,

Thies

3 answers

1 vote
Bobby Bailey
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.
August 2, 2023

Hi @Thies Uhlenbruch 

To prevent a user from starting a transition, you want to use a ScriptRunner condition.

As you have noted, you will need to write an Expression, the documentation for which can be found here: Jira Expressions

The expression you want will look like this:

issue.customfield_10457 == null || issue.customfield_10457.value != "Nein" || issue.customfield_10458 != null



To break down what we are doing here, the Query checks to see if the dropdown is null (empty), if it is, we return true and allow the transition, if not we fail that check and move on to the next.

The next check checks to see if the option that is selected in the dropdown is not "Nein". If it isn't (I.E., its "Ja") then this returns true and allows the transition, otherwise, it fails and moves on to the next check.

By the time we have gotten to the last check, we know that the dropdown is populated, and we know that the option selected is "Nein". Therefore, we can check the other custom field to see if it is populated. If it is, we return true and allow the transition, if it is not we fail this and therefore all checks and return false, knowing:

We have an option selected, its "Nein" and the other custom field is empty. 

When you are writing these logic statements, you can see what information you can extract from the issue using this Jira Expressions Type Reference. Here you will see how I accessed the data and what else you can use. 

Hope this helps! Please let me know how you get on!

0 votes
Thies Uhlenbruch
Contributor
July 31, 2023

Hi @Frederik Vantroys

thanks for your help but that doesn't meet my requirements. It's a little bit more complex .... to make it clearer:

 

The customfield _10457 has two Options ("Ja", "Nein") or can be left EMPTY

The customfield _10458 must be != EMPTY if the customfield_10457 is set to "Nein"

 

Cheers,

Thies

Frederik Vantroys
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 31, 2023

Maybe you can solve it by leaving the workflow as is and make an automation rule ?

 

- when : transition to done

- if field1 =nein and field2 = empty

...

transition to previous state

send message: can't set to done

 

Of course the item will have been set to done and back to in progress

0 votes
Frederik Vantroys
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 31, 2023

Hi @Thies Uhlenbruch ,

https://support.atlassian.com/jira-cloud-administration/docs/configure-advanced-issue-workflows/#Advancedworkflowconfiguration-validators

Here you can find how to implement a condition or validator in your workflow.

there is a compare number custom field condition and a value field condition that might help you out

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events