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
I think it is the field dependencies to other insight fields. If they are not filled in the correct order, then the value (or id) is discarded.
Hi @Christof Hurst ,
welcome to the Atlassian Community!
It seems to me the problem could be in the variable putObject.
When you want to store insight objects, the variable needs to be
List<ObjectBean>
i.e list of objects.
Where do you have this script? How do you obtain "objectBean"?
Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
the objectBean is fetched from various places. It's a general problem. But it's always the same class. In most cases it works with [objectBean.objectKey]. Maybe sometimes it fails because the customfield configuration depends on former fields to be set.
Nevertheless it works when setting the fields after creation via
createdIssue.setCustomFieldValue(cf,[objectBean])
In that case the objectBean was retrieved by
def objectBean = issue.getCustomFieldValue(cf)[0]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.