Script for hiding the transition of issue on the basis of the status of the linked issue?

What would be the script for hiding the current transition, if the transition of the Linked issue does not match some of the states?

For e.g.

I want to make "Submit for Approval" Hidden until the Linked Ticket Does not reaches to "Resolved"

* I have the Script Runner Plugin.

7 answers

1 accepted

0 vote
Henning Tietgens Community Champion Apr 17, 2013

Hi,

you can use Script Runner simple scripted condition and this script

IssueLinkManager issueLinkManager = ComponentAccessor.issueLinkManager
def found = issueLinkManager.getOutwardLinks(issue.id).any {it?.destinationObject?.statusObject?.name != 'Resolved'} || issueLinkManager.getInwardLinks(issue.id).any{it?.sourceObject?.statusObject?.name != 'Resolved'}
return !found

if you want to ignore the link type.

Henning

Henning Tietgens Community Champion Apr 17, 2013

This is not tested by me... :-)

it works in one jira system. now i built an application link between 2 jira systems,and the issue link is cross-jirasystem too.how can i edit the script?

for this you have to develop condition or use the Use the subtask blocking condition in JIRA workflow., i am not sure if it is there on script runner plugin

Hi Vineet, in fact you can make the Submit transition only available from the Resolved status using the workflow.

Check that the Submit it's only a transition for the Resolved step and that will do. Or, you can check with a validation if the field Resolution is not null to do the transition.

Hope this helps.

Hey Ramiro, the case is slight different. They both are different issues but Linked together.

In that case,If Issue "XYZ-2" is coming to Resolve than only the "Submit for Approval" of issue "YZX-4" should be visible else it will remain hidden in every case.

In that case you could use the Script Runner plugin with the Built-In script called Allows the transition if this query matches a JQL query.

With this you can do a JQL query that searchs for a linked issue that has a resolved status.

If the query finds one row then it will allow the transition.

That querry is my only question.

Hey Ramiro, the case is slight different. They both are different issues but Linked together.

In that case,If Issue "XYZ-2" is coming to Resolve than only the "Submit for Approval" of issue "YZX-4" should be visible else it will remain hidden in every case.

Herr Henning,

Can you help me on that?

Henning Tietgens Community Champion Apr 17, 2013

I don't get a notification for this. I don't know, is there something like mentioning in Answers?

He forgots the '@' in your name, maybe because of that.

Henning Tietgens Community Champion Apr 17, 2013

But it works :-)

Henning Tietgens Community Champion Apr 17, 2013

Mmmh. It's not visible while typing that @Henning Tietgens is a mention... Not like in Confluence.

0 vote
Henning Tietgens Community Champion Apr 17, 2013

Hi,

you can use Script Runner built-in condition "Allows the transition if this query matches a JQL query" and the query "issueFunction in linkedIssuesOf("status = Resolved", "blocks")" to check for linked issues with link type "blocks" and status Resolved.

Henning

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

231 views 1 18
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you