Hi there
I'm trying to auto update a custom field and a system field during transition by using ScriptRunner in JIRA Cloud.
I'm want to use POST method. Take note that I've tried with actual value but keep getting error. I guess my body isn't correct. I'm new to Groovy. Kindly assist.
Please find below code.
// Specify here the issue key for the issue to transition
def issueKey = '<issue name>'
//check if issue is assigned
def result = get('/rest/api/2/issue/' + issueKey + '?fields=assignee')
.header('Content-Type', 'application/json')
.asObject(Map)
if (result.body.fields.assignee.accountId != null)
{
// The ID of the workflow transition to execute.
// Note - The transition ID must represent a valid transition for the workflow that the issue uses.
def transitionID = '<transitionID>'
// The rest call to transition the issue
def transitionIssue = post("/rest/api/2/issue/${issueKey}/transitions")
.header("Content-Type", "application/json")
.body( [
fields: [
[
"customfield_10050": '5'
],
[
"summary": 'Task name from script'
]
]
,
transition: [id: transitionID]
])
.asObject(Map)
// Check if the issue was transitioned correctly
if (transitionIssue.status == 204) {
return "The ${issueKey} issue was transitioned to the status with the id of ${transitionID}"
} else {
return "The escalation service failed to transition the ${issueKey}issue. ${transitionIssue.status}: ${transitionIssue.body}"
}
}
I've managed to solve this. I'm unable to use update custom fields in the transition as the fields were not available. I was unable to get the fields although I tried to change the screen types in workflow transition.
So I managed to use PUT method to update fields.
See https://library.adaptavist.com/entity/calculate-custom-field-on-issue-update - adjusting a system field is just a case of using its name directly as you already are.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nic.. Thanks for the suggestion.. I'm trying to update the fields by using POST function when doing transition..
Please look at below script.
I got below error. Please assist.
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.