Hi community,
I want to create issues via groovy and want to set an Insight customfield. But I didn't get the correct syntax. Neither with object, objectId or objectKey I'm able to fill the field.
Did anybody have tips?
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.bc.issue.IssueService.IssueResult
import com.atlassian.jira.bc.issue.IssueService.CreateValidationResult
import com.atlassian.jira.component.ComponentAccessor
String[] putObject = [objectBean]
//String[] putObject = [objectBean.id]
//String[] putObject = [objectBean.objectKey]
Long cfId = 12345L
Long projectId = 11111L
String issueTypeId = "22222"
String summary = "TestSummary"
def reporter = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def issueService = ComponentAccessor.issueService
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters
.setProjectId(projectId)
.setIssueTypeId(issueTypeId)
.setSummary(summary)
.setReporterId(reporter.name)
issueInputParameters.addCustomFieldValue(cfId, putObject)
CreateValidationResult createValidationResult = issueService.validateCreate(reporter, issueInputParameters)
if (createValidationResult?.isValid()) {
IssueResult createResult = issueService.create(reporter, createValidationResult)
if (!createResult.isValid()) {
return null
} else {
return createResult.issue
}
}
return null