Hi Guys,
I am hoping to take the source script from the "Previous status" function in JIRA and add it as a simple script condition to block a transition if the workflow has been in "System Testing" status before. This would be designed to block access to one workflow branch and direct the issue down another branch.
Please can someone help me with this script change for this code. Please see the attached screenshot for details.
PrevStatus.jpg
Thanks,
David
Here a code that test if an issue has been in status:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.changehistory.ChangeHistory import com.atlassian.jira.issue.history.ChangeItemBean for(ChangeHistory changeHistory: ComponentAccessor.getChangeHistoryManager().getChangeHistories(issue)) { for(ChangeItemBean changeItemBean: changeHistory.getChangeItemBeans()) { if (changeItemBean.getField().equals("status")) { if(changeItemBean.getFromString().equals("System Testing")) return false } } } return true
Slightly Groovier version of Vasiliy's code:
import com.atlassian.jira.component.ComponentAccessor def changeHistoryManager = ComponentAccessor.getChangeHistoryManager() def wasItEverInSystemTesting = changeHistoryManager.getChangeHistories(issue).any { changeHistory -> changeHistory.getChangeItemBeans().any { changeItemBean -> changeItemBean.getField() == ("status") && changeItemBean.getFromString() == ("System Testing") } } return !wasItEverInSystemTesting
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.