Hi,
I am trying to create a new issue from an existing one through scriptrunner postfunction. Below is my code
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.user.ApplicationUser
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("DK-3814")
def groupManager = ComponentAccessor.getGroupManager()
String groupName = "ng-ngage-jira-users"
//****Declaration for Required Fields for Creation of Release****//
def assignee= issue.getAssigneeId()
def productVersion = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Product Version")
def productVersionValue = (String) issue.getCustomFieldValue(productVersion)
def ProductName = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Product Name")
def ProductNameValue = (String) issue.getCustomFieldValue(sdlProductName)
//****End of Declaration for Required Fields****//
//****Declaration for Optional Fields (user related) for Creation of Release****//
def Manager = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName(" Manager")
def ManagerValue = issue.getCustomFieldValue(Manager)
IssueService issueService = ComponentAccessor.getIssueService()
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters();
issueInputParameters
.setProjectId(issue.getProjectObject().getId())
.setSummary(issue.summary)
.setDescription(issue.description)
.setIssueTypeId(issue.issueTypeId)
.setPriorityId(issue.priorityId)
.setReporterId(issue.reporterId)
.setAssigneeId(assignee)
.addCustomFieldValue(productVersion.getId(),productVersionValue)
.addCustomFieldValue(ProductName.getId(),ProductNameValue)
.addCustomFieldValue(Manager.getId(),ManagerValue)
IssueService.CreateValidationResult createValidationResult = issueService.validateCreate(user, issueInputParameters)
log.error("issue input parameters: " + issueInputParameters.getActionParameters())
if (createValidationResult.isValid())
{
log.error("createValidationResult")
IssueService.IssueResult createResult = issueService.create(user, createValidationResult)
if (!createResult.isValid())
{
log.error("Error while creating the issue.")
}
}
When I try to execute it I get an error. I am unable to figure out what is the mistake here. Can someone please guide?
