Forums

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

Custom field decides whether to see the next Transitions

彥宏(Luke) 劉
Contributor
July 20, 2023

I have a Single Select custom field, the options are only "Yes" and "No", I want to know how to use Script to help me, today I choose "Yes" to see the next Transition, otherwise the Transition will be hidden.

Ps. Custom field in the transition screen

Jira 7.19
Scriptrunner 5.5.6

1 answer

1 accepted

2 votes
Answer accepted
Nic Brough -Adaptavist-
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 21, 2023

You can't do this during a transition, because a transition has a fixed endpoint that you cannot change after you've decided to go there.   But you can do it before the transition starts, or after it ends.

The two tricks are both workflow based.  I'm going to imagine a part of your workflow and try to keep it simple.  Let's say you have three status in it - analysis, coding, and ask-question.  With your question leads me to a definition of "When the issue is in analysis, if my select list (called "more questions?") is set to yes, go to ask-question, and if no, the next status is coding"

For trick one

  • Set up your workflow such that you have analysis -> ask-question -> coding.
  • Scriptrunner has a function for "fast track transition" - use one of these, configured to
  • look at issues arriving in ask-question
  • check the field for a "no"
  • if it finds one, automatically transition to coding

Pros and cons

  • P: You can use the field on the transition screen, the check looks at the current content that was committed to the change
  • C: Both transitions will appear in the history
  • C: Unless you use a transition name that is fuzzy (could describe both status), you could confuse your users as to what is going on.  Even if you use a fuzzy one, you will probably need to explain it to your people too

This will skip your issue through ask-quesion straight into coding when the field is "no"

Trick two is probably more intuitive for your users, and won't litter your history with a transition to a status that isn't actually going to be acted on.

  • Set up your workflow with two transitions out of analysis:
    • Analysis -> ask-question
    • Analysis -> coding
  • Now add oppositional workflow "condition" to both transitions
    • On one, you put in the condition "field = Yes"
    • The other needs "field = No"
    • (In real life, you'll probably have more options, so I would actually use something more like "field = Yes" and "field is not Yes, or empty")

Pros and cons

  • P: Your users don't have to think, beyond knowing to set the field as they should
  • P: Clean history
  • C: Your users will have to edit the field before trying to change the status, they can't do it during the transition

When your users look at an issue in analysis, they will only be offered one of the transitions and it will be the one determined by the current content of the field

Suggest an answer

Log in or Sign up to answer