The code that I trying run is it:
...
def issueInputParameters = issueService.newIssueInputParameters().with {
setProjectId(project.id)
setIssueTypeId(issueType.id)
setReporterId(loggedInUser.name)
setSummary(summary)
setPriorityId(priorityId)
setComponentIds(component as Long)
setDescription(description)
addCustomFieldValue(data_field_id, data as String)
addCustomFieldValue(area_solicitante_field_id, "Department -> IT")
}
def validationResult = issueService.validateCreate(loggedInUser, issueInputParameters)
if (validationResult.isValid()){
def result = issueService.create(loggedInUser, validationResult)
}else{
return validationResult.getErrorCollection()
}
But I give this error:
Errors: {customfield_17401=The option 'Department -> IT' is an invalid parent option} Error Messages: []
How parse data correctly to fill this error?
Hi!
For searchers like me )
To set 2nd level add ":1" to custom field Id:
def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectsByName("Your Cascade field name")[0]
def issueInputParameters = issueService.newIssueInputParameters().with {
...
addCustomFieldValue(cf.getId(), 'Parent value text or Id number')
addCustomFieldValue(cf.getId() + ":1", 'Child value text or Id number')
}
Hi @Rafael Costa! Create first the issue with the parent field. (Also I mean don't put the child field in the creation process). After having the issue created, then update the issue, filling the child field.
Good luck!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Rafael Costa
look at the following script excerpt, precisely that is what I say, you can create first the Issue, and after that (probably based on your conditions - selecting the child field) update then the Issue; in my case, I'm assigning it after creation (I could have done the creation with the assignment at once, but I needed to do it in two steps.):
def issueInputParameters = issueService.newIssueInputParameters().with {
setProjectId(project.id)
setIssueTypeId(issueType.id)
setReporterId(reporter.toString())
setSummary(summary)
setDescription(description)
setPriorityId(priorityId)
addCustomFieldValue("customfield_16873", objectData.objectKey as String)
}
def validationResult = issueService.validateCreate(loggedInUser, issueInputParameters)
assert validationResult.valid : validationResult.errorCollection
def result = issueService.create(loggedInUser, validationResult)
assert result.valid : result.errorCollection
def String issueKey = result.getIssue().getKey()
def issue = issueManager.getIssueObject(issueKey)
def userAssignee = userManager.getUserByKey(assignee.toString())
def validateAssignResult = issueService.validateAssign(userAssignee, issue.id, issue.reporterId)
assert validationResult.valid : validateAssignResult.errorCollection
def resultAssign = issueService.assign(userAssignee, validateAssignResult)
assert resultAssign.valid : validateAssignResult.errorCollection
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can take a look at this example :
https://library.adaptavist.com/entity/set-a-default-option-on-a-cascading-select-list
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The context is different, this link show how set a cascading field, but I need create an issue with the field filled.
The problem was in the child option. I could create an issue with parent option only and child as null, so I create the issue, retrieve it, then set the child option.
it was not as presented on the link, but help me to create my own script, thanks!
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.