Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Setting transition property during post function

Is it possible to set a transition's property in particular opsbar-sequence property in post function?

1 answer

0 votes

Hi @Joel Batac, I haven't tried it myself, but I believe there is a way you can do that. I googled around and came across similar posts that might help you to get more insights into this. Also, if you can provide more details of your use case, we might be able to come up with alternative solutions and suggestions if applicable.

HI Ivan, thanks for the response.  

Basically I have a workflow (pls see attached image), where from New status it can transition to any of 4 statuses -Research and Analysis, Architecture Assessment, Pending Review and Ready to Refine.  And all those those 4 statuses can transition to each other as well as go back to New.

My user what to see the transition button to follow  - 
New > Research and Analysis > Architecture Assessment > Pending Review > Ready to Refine.

I set the opsbar setting as :

Cancel = 10

Research and Analysis = 20

Architecture Assessment = 30

Pending Review = 40

Ready to Refine = 50

The first 2 times of transitioning are fine, - from New to Research and Analysis, from Research and Analysis to Architecture Assessment. But after the second transition, it shows Research and Analysis again, which is expected based on the opsbar setting. I want to show Pending Review instead.  And after this, Ready to Refine.

How can this be achieve?


first transition.pngsecond transition.pngthird transition.pngworkflow.PNG

Ivan Lima Community Leader Aug 28, 2022

Before we get into this rabbit hole, which version are you in and what are the plans to upgrade to Jira 9.x version? I'm saying it because the issue status and transitions have a different look and feel from Jira 9 onward, and the effort you're putting into this may not make sense once you upgrade. I'm trying to help you understand whether the juice is worth the squeeze in your case.

we're using version 8.20.8

Ivan Lima Community Leader Aug 29, 2022

Right. Did you check the link I shared with the new view for issue status and transition? Do you know when you're instance will get upgraded to 9.x?

Now, back to your implementation, did you try to put a code together based on the references I shared initially? I can try to carve out some time this week to attempt this if nobody else chimes in here.

Hi Ivan,

 I tested the script in post function to set Research and Analysis transition opsbar setting  from 10 to 60 but got the ff: 

at com.atlassian.jira.workflow.AbstractJiraWorkflow.getLinkedStep(
at com.atlassian.jira.workflow.JiraWorkflow$ Source)



import com.atlassian.jira.component.ComponentAccessor

Map attributes = new HashMap()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def workFlowManager = ComponentAccessor.getWorkflowManager()
def workflow = workFlowManager.getWorkflow("Standard Template Initiative Workflow")
def status = ComponentAccessor.getConstantsManager().getStatus("Research and Analysis")   /// this is line #9
def stepDescriptor = workflow.getLinkedStep(status)
workFlowManager.updateWorkflow(user, workflow)

The code above didn't work for me either. Therefore, I put this one together and tested it with a simple workflow, which worked. Give it a try. I suggest you try it in the script console before diving into your logic so you can confirm it's working as expected.

import com.atlassian.jira.workflow.WorkflowManager
import com.atlassian.jira.component.ComponentAccessor
import com.opensymphony.workflow.loader.ActionDescriptor

def workflowManager = ComponentAccessor.getWorkflowManager()
def workflow = workflowManager.getWorkflow("YOUR WORKFLOW NAME")

Collection<ActionDescriptor> actionToDo = workflow.getActionsByName("To Do")
Collection<ActionDescriptor> actionInProgress = workflow.getActionsByName("In Progress")
Collection<ActionDescriptor> actionDone = workflow.getActionsByName("Done")

Map<string, string> map1 = new HashMap()
map1.put("opsbar-sequence", "10")

Map<string, string> map2 = new HashMap()
map2.put("opsbar-sequence", "20")

Map<string, string> map3 = new HashMap()
map3.put("opsbar-sequence", "30")

cool..thanks for this. Although i found a workaround before seeing this, still appreciated the help.


Workaround was to update the XML and rearrange the 'common-action id' entries for each steps - putting the first transition at the top.



<step id="4" name="Architecture Assessment">
<meta name="">43200</meta>
<common-action id="391" />  #### Pending Review transition
<common-action id="401" />
<common-action id="381" />
<common-action id="411" />

Ivan Lima Community Leader Aug 30, 2022

I'm glad you found a workaround, but I suppose you're not setting it during a post-function nor using scriptrunner, are you?

That's right. Basically hard coded.  The only requirement from user is to have the next transition next to Cancel 

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events