Hello, I am creating a script so that when an incident goes to the "Cancelled" state, the subtasks are changed to the same state, I managed to make it work but they were changed with any change of state, so I added an "IF" to validate that the status of the parent issue is ID:7, but it did not succeed, try "if (issueInfo.body.fields.status.id == "7") {" to compare the parent issue to see if it met the condition. What could I use to compare the status of the parent issue "if (XXXXXXX == "7") {"
def parentKey = 'SCRIP-116'
def parentIssueInfo = get("/rest/api/2/issue/${parentKey}")
.queryString("fields", "status")
.asObject(Map)
assert parentIssueInfo.status == 200
if (XXXXXXX == "7") {
def jqlQuery = 'parent = "${parentKey}"'
def doneTransitionId = 9362
def allSubTasks = get("/rest/api/2/search")
.queryString("jql", jqlQuery)
.asObject(Map)
assert allSubTasks.status >= 200 && allSubTasks.status <= 300
def subtaskIssues = allSubTasks.body.issues as List<Map>
subtaskIssues.each { subtask ->
def transition = post("/rest/api/2/issue/" + subtask.key + "/transitions")
.header("Content-Type", "application/json")
.body([transition: [id: doneTransitionId]])
.asObject(Map)
assert transition.status >= 200 && transition.status <= 300
}
} else {
logger.info("La incidencia padre no está en el estado deseado para la transición.")
}
First of all, thank you
Regards
Hi Marcello,
I think your condition needs to be like parentIssueInfo.body.fields.status.statusCategory.id
The reason is that the status ID is below a statusCategory property.
The way I found this was to run the rest of the call to get the parent issue on the script console and to look at what the status field structure returned is.
I hope this helps.
Regards,
Kristian
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.