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 (
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:-
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")
def sampleIssuePickerValue = sampleIssuePicker.getValue(issue) as List<String>
def availableIssueLinkTypes = issueLinkTypeManager.issueLinkTypes
def linkType = availableIssueLinkTypes.findByName("Blocks")
def sequence = 1L
def destinationIssue = issueManager.getIssueByCurrentKey(it.toString())
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,
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