Forums

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

Scriptrunner Issue picker field value to linked Issue

Venkat Krishnamoorthy
Contributor
November 23, 2020

Hello,

We are planning to use Issue picker field and convert it to a Jira Linked Issue of a "particular type".

Currently, I created a Multi-Select Issue Picker field and added it to the screen. All the picked Issues for that field need to be added as Linked Issues of "certain link type" with "Outward link Description". I hope that will automatically create the reverse Issue link with "Inward Link Description".

 How to best implement this? Please assist.

 

Thanks

Venkat

2 answers

0 votes
Александр Храмков
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 11, 2023

Hi, that's how I solved this problem: script has set the task creation postfunction

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkTypeManager
import com.atlassian.jira.issue.*
import com.atlassian.jira.issue.fields.CustomField
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import com.atlassian.jira.issue.link.IssueLink

@BaseScript FieldBehaviours fieldBehaviours

final def linkName = "Blocks"

def customField = ComponentAccessor.customFieldManager.getCustomFieldObject(16535)
def linkType = ComponentAccessor.getComponent(IssueLinkTypeManager).issueLinkTypes.find{ it.name == linkName }

def stories = issue.getCustomFieldValue(customField) as List<Issue>
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser


// create new link "Blocks" 
if (stories) {
    stories.each { contactIssue ->
        ComponentAccessor.issueLinkManager.createIssueLink(contactIssue.id, issue.id, linkType.id, 0L, user)
    }
}
0 votes
Luiz Gregorio March 17, 2021

Hi Venkat, looking for this solution too.

Did you manage to solve this?

Suggest an answer

Log in or Sign up to answer