I have an issue picker field called 'Linked issue selection'. I'm trying to link the current issue to the issue selected in the picker field via a script. Here is the code:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.customfields.manager.OptionsManager
def id = issue.getId()
def issuePickerField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Linked issue selection")
def issuePickerFieldValue = issue.getCustomFieldValue(issuePickerField) as Issue
def issuePickerFieldIssueId = issuePickerFieldValue.getId()
def linkManager = ComponentAccessor.getIssueLinkManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() as ApplicationUser
linkManager.createIssueLink(id, issuePickerFieldIssueId, 10003, 1, user)
The error rendered states:
"Error
We were unable to submit your request. Please refresh the page and try again. Note that this will clear your request details.
If you have already tried again, contact your Jira Administrator."
This post-function is located in the create transition as the 5th post-function. When the post-function is disabled the issue is created with no error.
Thank you