Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

ScriptRunner Creating Linked issues from a behaviour

Peter Ellis
Contributor
December 13, 2023

Hi,

I am using ScriptRunner to create some fragments to give me additional options behind the 'More' button within a project. I have corresponding behaviours that take the names of these fragments and creates a new linked issue. Works perfectly, however the only 'issues-linktype' that it works with is "relates to", it fails to create the link on either the underlying issue or the newly created one with any other 'issues-linktype'. The code is below. Any ideas as to why this is not working? 

import com.atlassian.jira.component.ComponentAccessor


def issueManager = ComponentAccessor.getIssueManager()

if (getBehaviourContextId() == "create-issue-pmo") {
    getFieldById("project-field").setReadOnly(true)
    getFieldById("issuetype-field").setReadOnly(true)
    def contextIssue = issueManager.getIssueObject(getContextIssueId())
    getFieldById("issuelinks-linktype").setFormValue("relates to").setReadOnly(true)
    getFieldById("issuelinks-issues").setFormValue(contextIssue.key).setReadOnly(true)
    getFieldById("assignee").setFormValue(contextIssue.assigneeId).setReadOnly(false)
}

1 answer

1 accepted

0 votes
Answer accepted
Dave Rosenlund _Trundl_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 13, 2023

Hi, @Peter Ellis 👋

I added scriptrunner and adaptavist tags to your post to hopefully draw some of those eyeballs here, too. 

Good luck,

-dave

Peter Ellis
Contributor
December 14, 2023

Cheers Dave

Peter Ellis
Contributor
December 15, 2023

I found the answer - it's one of those where you kick yourself! I was only testing one of the links throughout the testing and I had another behaviour, which was checking other fields that I wanted to check, working on the same issue type/project combo. They were obviously clashing as once I disabled the other one it worked perfectly. I have combined them now and it works ! 

Like • Dave Rosenlund _Trundl_ likes this

Suggest an answer

Log in or Sign up to answer