Is it possible to link issues via wf post function Script?

Harsh
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.
August 10, 2023

Hi All,

I have 4 status in PROJECT 1-
Open -> In Progress -> In Review -> Resolved.


Step 1

I have a ticket in PROJECT 1; when the ticket is moved from Open -> In Progress; it automatically creates a ticket  in PROJECT 2 and links to PROJECT 1 ticket with link type 'has dependency'. 

Step 2

Now, when the above created ticket in PROJECT 2 is cancelled, the PROJECT 1 ticket(which was in IN PROGRESS status) moves to IN REVIEW, which in turn creates another ticket in PROJECT 2(but with different summary, I am setting the summary and description via scripting).

My question: is it possible to link (type - 'is caused by') the ticket created in Project 2(Step 2: IN REVIEW transition) to the ticket in PROJECT 2 which was cancelled(created when IN PROGRESS status) before in Project 2(based on summary), via post function or JIRA automation.

I tried via automation but no luck. If this is possible can via scripting can some one help!

Thank you.

2 answers

1 vote
Nic Brough -Adaptavist-
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.
August 10, 2023

Yep, if you have Scriptrunner, these are both possible.

The first is surprisingly easy if you have a recent version of SR (one with HAPI capabilities)

From memory:

// Create a new issue
def newIssue = Issues.create('projectKey', 'issueType') {
    setSummary('New issue')
}

// Link the new issue to the existing issue
issue.link('linkType', newIssue)

The second is a bit more involved, but you should be able to find snippets and examples to help you with it in https://library.adaptavist.com

Harsh
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.
August 11, 2023

Hi @Nic Brough -Adaptavist- 

 

For the first one I had already implemented the logic and it works perfectly, since it's a straight default post function (clone funtion in wf). 

Since for step 2: the requirement, is to link the issue which is getting created when it goes to in review status to the ticket which was triggered in step 1 and is cancelled. 

 

Thanks again for the help. Any suggestions would be a great help. I think it's a bit tricky. 

Harsh
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.
August 12, 2023

Thanks!

0 votes
Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 10, 2023
Harsh
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.
August 11, 2023

Hi @Fabio Racobaldo _Herzum_ 

 

Thanks for the reply. I did try but it works when you are creating a issue in one transition. 

It is not working in my scenario. If you have any test script that fits the scenario would be a great help. 

 

Thanks again!

Suggest an answer

Log in or Sign up to answer