Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How can I transition an issue state only after two custom fields have been updated?

Tom J February 20, 2021

I have an issue I'm trying to transition when a custom date, and custom hash field are updated, but only if another field is in the approved state. This last one is a button transition back to the current state (done by someone and would be a lot of work to change). So I'm trying to just leave it alone.

 

So, what I'm trying to do now is use a listener to only transition the issue to the next state in the workflow external review if both variables have been updated and are not set to empty. However, I can only get it to work for a single custom field update. Any ideas on how I could make this listener depend on both being changed?

 

I tried to detect a change in both fields in the same listener script and only transition if both are changed, but that doesn't seem to work (maybe it's not timed right).

 

Any idea on how to handle a two field update transition? I haven't run across any questions that could help me solve this. I'm using Jira 8 by the way, and scriptrunner.

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 20, 2021

Here is how I would rephrase your rule... does that seem correct?

When

  • either field A or field B is changed

If

  • both fields contain a value

Then

  • trigger the transition

Or is it important that both fields have just been changed either together via the edit screen or in short succession (perhaps within the last x minutes) via in-line edits?

In the case of screen edit, I think both fields should be in the event.changeLog. But for in-line edits, you would get 2 separate events. So then you need to only fire on the second event, and only if the other field was also recently changed. You'll have to decide what the appropriate time threshold is. And then call the changeHistoryManager to get all the recent changes to see if the other field was also modified.

Tom J February 22, 2021

It's important for both of the fields to have changed. I was going to try your idea of using a time threshold but I couldn't figure out how to get the number of minutes since a change was made to the field. I also wasn't sure how to trigger the listener to fire the right event to play off of the other field to make this work. Currently, I just have the one listener, and I'm not able to detect changes except right when they happen. So, I'm not sure how to handle a change that happened, say 2-3 minutes ago, which would be a reasonable time to allow the ticket transition.

 

Ideally what I want to do is have it auto-transition in whatever order I do it in. So whether the approvals come first, or whether the fields are changed and then the approval transition occurs.

TAGS
AUG Leaders

Atlassian Community Events