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

Vineet Kumar April 17, 2013

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 votes
Answer accepted
Henning Tietgens
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2013

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

zhao ninglong March 25, 2015

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?

0 votes
Vineet Kumar April 18, 2013

@swati sneha

0 votes
Henning Tietgens
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 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

0 votes
Vineet Kumar April 17, 2013

Herr Henning,

Can you help me on that?

Henning Tietgens
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2013

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

Ramiro Pointis
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2013

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

Henning Tietgens
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2013

But it works :-)

Henning Tietgens
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2013

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

0 votes
Vineet Kumar April 17, 2013

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.

0 votes
Ramiro Pointis
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2013

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.

Vineet Kumar April 17, 2013

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.

Ramiro Pointis
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2013

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.

Vineet Kumar April 17, 2013

That querry is my only question.

0 votes
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2013

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

Suggest an answer

Log in or Sign up to answer