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 (
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.
2) In the Post-Function config, click on the Add post function link.
3) Next select the Custom script post-function [ScriptRunner] option.
4) Once you are on the Custom script post-function page, you can add the sample code as shown in the print screen below.
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:-
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:-
I hope this helps to solve your question. :)
Thank you and Kind Regards,
Ram
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.