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 to Restrict a workflow transition based on component lead(in post functions,conditions etc)

Hi Team,

I want to restrict a workflow transition based on component lead. Could you please help me on this.

Scenario: when user creates an issue they will select Component related to their issue. As we know, each component in project will have it's component lead.The same component lead should be able to make a transition in workflow. Could you please help me on how to implement this. Thank you.

 

Regards,

Syam

2 answers

1 vote

Hello,

You would need an add-on for it.

For example, you could use the Power Scripts add-on:

https://marketplace.atlassian.com/apps/43318/power-scripts-jira-script-automation?hosting=cloud&tab=overview

You could write a condition with a code like this:

for (string comp in components) {
if (getProjectComponentLead(project, comp) == currentUser()) {
return true;
}
}
return false;

@Alexey Matveev _cPrime_  I am using Scriptrunner but it looks like the following ALWAYS returns true

import com.atlassian.jira.component.ComponentAccessor

def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser

return issue.components.find { c ->
c.componentLead.key == currentUser.key
}


 I have also tried saving the search to a found user and comparing that with the current user. No joy :(

 

UPDATE:

Using the script console I discovered I was wrong,  this returns null but the transition is permitted. This is a workflow condition so I would expect null or false to prevent the transition. Very confusing indeed.

mmm Ok i have resolved this...

 

/**
* Only a Component Lead can approve a request
*
*/
import com.atlassian.jira.component.ComponentAccessor

def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def leads = issue.components.collect {
it.lead
}

return currentUser.key in leads

Hi @syamasundararao ratti,

 

Natively this is not possible to transition an issue based on the component lead. You need a Power Scripts addon. This will gives you a validator option.

Here is the tutorial for the same.

https://confluence.cprime.io/display/TR/Validator+for+component+lead#app-switcher

 

Thanks,

Sravya

Suggest an answer

Log in or Sign up to answer
TAGS

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