Hi,
While creating a new issue using scriptrunner, I would like to assign it an existing epic. it seems the issue.setCustomFieldValue(epicLinkCustomField) is not working. any help would be greatly appreciated.
The code I have is below.
Hi @Michael Venable ,
welcome to the Atlassian community!
there are some errors in your script.
Hope this helps,
Fabio
Hi, So i updated my script as follows:
// Replace these placeholders with your own values
def projectKey = "SEC"
def reporter = "MV108788"
def assignee = "MV108788"
def description = "This is the description for the new issue."
def summary = "New issue summary"
def priority = "Low"
def issueType = "Task"
def epicKey = "test"
// Get the issue type and priority objects
def issueTypeManager = ComponentAccessor.getIssueTypeManager()
def priorityManager = ComponentAccessor.getPriorityManager()
def issueTypeObject = issueTypeManager.getIssueType(issueType)
def priorityObject = priorityManager.getPriority(priority)
// Set up the input parameters for the new issue
def inputParams = new IssueInputParametersImpl()
inputParams.setProjectKey(projectKey)
inputParams.setReporter(reporter)
inputParams.setAssignee(assignee)
inputParams.setDescription(description)
inputParams.setSummary(summary)
inputParams.setPriority(priorityObject)
inputParams.setIssueType(issueTypeObject)
inputParams.setFieldValue("EpicLink", epicKey) // Replace "customfield_123" with the actual field ID of the epic link field
// Create the new issue
def issueService = ComponentAccessor.getIssueService()
def createValidationResult = issueService.validateCreate(ComponentAccessor.getJiraAuthenticationContext().loggedInUser, inputParams)
if (createValidationResult.isValid()) {
def createResult = issueService.create(ComponentAccessor.getJiraAuthenticationContext().loggedInUser, createValidationResult)
if (!createResult.isValid()) {
throw createResult.errorCollection.getErrorMessages()
}
} else {
throw createValidationResult.errorCollection.getErrorMessages()
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.