Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Scriptrunner Issue picker field value to linked Issue

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

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)
    }
}

Hi Venkat, looking for this solution too.

Did you manage to solve this?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events