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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How hide workflow transition base on component selection?

I'm trying to hide workflow transitions base on component selection. I created Behaviour script and getting errors. How I can declare a workflow transition? How I can accomplish this?

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.workflow.TransitionOptions
import com.atlassian.jira.bc.project.component.ProjectComponent
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours

def action = workflowManager.getActionsByName("Done")
def approved = workflowManager.getActionsByName("In Progress")
def components = getFieldById(getFieldChanged()).value as List<ProjectComponent>
if(components.any{it.name == 'Sales'}){
action.setHidden(true)
}
if(components.any{it.name == 'Support'}){
approved.setHidden(true)
}


scriptrunner_112020-01.pngscriptrunner_112020-02.png

Thank you

1 answer

0 votes
Daniel Ebers Community Leader Nov 21, 2020

Hi Shah,

while I cannot help with the code itself I'd like to confirm we did something like this in the past using a simple scripted validator:

https://scriptrunner.adaptavist.com/6.14.0/jira/recipes/workflow/validators/simple-scripted-validators.html

On the contrary to what you wrote we did not use a Behaviour, though.
We also not aimed towards hiding the transition (condition) but show a error message to the user (validator).

Probably this would be an alternative for you? If so, the above linked documentation should help you to get an idea.

Cheers,
Daniel

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

110 views 1 8
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you