Link current viewed issue to create issue as POST function - ScriptRunner

Good morning,

I'm currently trying to write a post function script (Jython) to create a link between two issues on create. For us, we're trying to view a user story, then click create issue and make a requirement. Upon creation, we want to link the user story with the requirement. I've looked around about this and found a few examples on this page http://www.denizoguz.com/2013/06/29/jiraautomatically-linking-issues-with-a-script-during-create-transition/

I'm unsure how to continue. I've written small scripts before, so I'm not worried about not understanding what I'm doing, I'm just unsure how to proceed.

Thank you

1 answer

1 accepted

This widget could not be displayed.

The examples on your link are for groovy (script runner), rather than python (jira scripting suite).

Either way, you will be wanting the javadoc for com.atlassian.jira.issue.link.IssueLinkManager and com.atlassian.jira.issue.CustomFieldManager.

Okay! My biggest issue, is I'm not sure how I'm supposed to get the current issues ID so I can link to it. I know the tutorial I posted mentioned you put a custom ID in there, but I'm not sure if we're able to right now. I just assumed there might be another way.

Current issue is available in the binding as issue. So to get the id you do issue.id.

I think I mistyped my previous explanation.

When you are viewing an issue, and you click "Create Issue" on the top bar, the screen comes up to create an issue. When you click create and the issue is created, I'm trying to get the ID of the issue I was viewing while creating the issue. That way I can link the to. Does issue count for the viewed issue? or for the created issue?

Hrm... a better option might be to default some field to the issue that is currently being viewed with javascript.

If not, I don't know whether you can get the currently viewed issue from the user's session, although there won't always be a session, eg rest api requests.

You can get the most recently viewed one from user history but that might not be what you want.

That sounds like a start to me anyway. I'll work off of that! Thanks!

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

143 views 2 0
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