Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

ow to use script runner or automations to link all the tasks from the field

Good afternoon.
Please tell me how to use script runner or automations to link all the tasks from the field - "issue (s) piker" with the request on which this field is located.

I'm not good at scriptrunner (

1 answer

Hi @Evgeniy,

For your requirement, you could the Post-Function in the Create transition. 

I assume that you have already added an issue picker field for your project. 

You will next need to set up the Post-Function.

Below are the print screens of the Post-Function configuration:-

1) Go to the project's workflow. Switch to the Diagram view. Next, click on the Create transition and select the Post-Function link.

image1.png

2) In the Post-Function config, click on the Add post function link.

image2.png

3) Next select the Custom script post-function [ScriptRunner] option.

image3.png

4) Once you are on the Custom script post-function page, you can add the sample code as shown in the print screen below.

image4.png

Below is the sample code for your reference:-

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkTypeManager

def customFieldManager = ComponentAccessor.customFieldManager
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def issueLinkManager = ComponentAccessor.issueLinkManager
def issueLinkTypeManager = ComponentAccessor.getComponent(IssueLinkTypeManager)
def issueManager = ComponentAccessor.issueManager

def sampleIssuePicker = customFieldManager.getCustomFieldObjectsByName("Sample Issue Picker")[0]
def sampleIssuePickerValue = sampleIssuePicker.getValue(issue) as List<String>

def availableIssueLinkTypes = issueLinkTypeManager.issueLinkTypes
def linkType = availableIssueLinkTypes.findByName("Blocks")
def sequence = 1L

sampleIssuePickerValue.each {
def destinationIssue = issueManager.getIssueByCurrentKey(it.toString())
issueLinkManager.createIssueLink(issue.id,destinationIssue.id,linkType.id,sequence,loggedInUser)
}

Please note this sample code is not 100% exact to your environment. Hence, you will need to make the required modifications.

After adding the code, click on the Update button.

5) Once you have updated the post-function, you will need to bring the post-function to the very bottom as shown in the image below:-

image5.png

Once you have done that, click on the Publish button to publish your workflow changes.

Now you can try to create an issue and select the issues from the Issue Picker  Once the ticket is created, you should see the linked issues as shown in the images below:-

image6.png

image7.png

I hope this helps to solve your question. :)

 

Thank you and Kind Regards,
Ram

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you