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
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!
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Thies Uhlenbruch ,
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.