Forums

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

Workflow conditions

Juan Casals de la Fuente July 22, 2022

Hello,

I want to create a condition:
If the workflow goes A-->B--D and back to A the next time it only can go to D (not to B or C)

Something like: if goes from D to A it can only go back to D

Is that possible?

 

Thanks


Jira.jpeg

1 answer

0 votes
Jonathan V.
Contributor
July 22, 2022

Hi Juan, if I understand correctly, you would want the user/customer to transition to a status, and then only allow them to transition back to that status, correct?

If so, then this can be done, as I have implemented this very same behavior for our organization.

To do this, you need to leverage the history of the ticket's workflow and add a condition that will only show the transition if it previously came from the previous status.

Using your example above (D->A -> D), here is a code snippet which shows the condition that needs to be met if the ticket sits in status A. Please keep in mind, this is using ScriptRunner plugin to check for the condition.

 

import com.atlassian.jira.component.ComponentAccessor 

//Gets List of all changes to 'status' and takes from last one in the list

def changeItem = ComponentAccessor.getChangeHistoryManager().getChangeItemsForField(issue, 'status')?.last()

//variable 'from' is the previous state, 'String' for String type

changeItem?.fromString == "D"
Juan Casals de la Fuente July 22, 2022

HI! Thanks for your answer. And is there a way to do that without externar plugins?

Yes, is correct. If comes from D to A only can go back to D again

Jonathan V.
Contributor
July 22, 2022

Based on my experience, you will need some form of an external plugin, as there is no native way of doing this in Jira.

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