Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,553,216
Community Members
 
Community Events
184
Community Groups

Jira DataCenter - ScriptRunner - Auto-transition on subtasks not working

Hello,

I had a ticket open for this in Adaptavist support as well. 

We upgraded our Jira Server and all add-ons including ScriptRunner to Data Center this past weekend. We upgraded ScriptRunner by several versions during this process.

After the migration, our users noticed that the auto-transition of subtasks was working on and off. I am including the script here. This script works at times and other times I dont think it does anything. We added some log warn statements to follow the script execution but nothing is seen in the logs. However, the screen status says it successfully executed for a Jira Issue and we can confirm that in the Payload.

Last night, I spent some more time troubleshooting and it turned out commenting out the following line in the script - "setSkipScreenCheck(true)", fixed the Issue. No comments are being added to the subtasks during the transition but that is less of an Issue now. I understand "setSkipScreenCheck(true)" is to add comment on a ticket when the field is not available on the Edit screen. Not sure why that would affect the transition, though.

 

Here is the original Parent Issue PostFunction script

import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.issue.fields.CustomField

CustomField deplInEnv = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Deployed in Environment")

IssueService issueService = ComponentAccessor.getIssueService()
def user = ComponentAccessor.getUserManager().getUserByName("automation")
for(Issue subTask:issue.getSubTaskObjects()) {
if ((subTask.getStatusId() == "10102") && ((!subTask.getCustomFieldValue(deplInEnv)) || (!subTask.getCustomFieldValue(deplInEnv)*.value.contains('Stage')))) {
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.with {
setComment("Moving subtasks to ToDo from Parent Deployment Request")
setSkipScreenCheck(true)
}
// validate and transition subtask
def validationResult = issueService.validateTransition(user, subTask.getId(), 111, issueInputParameters)
if (validationResult.isValid()) {
def issueResult = issueService.transition(user, validationResult)
if (! issueResult.isValid()) {
log.warn("Failed to transition subtask ${subTask.key}, errors: ${issueResult.errorCollection}")
}
} else {
log.warn("Could not transition subtask ${subTask.key}, errors: ${validationResult.errorCollection}")
}
}
}

Thanks
Venkat

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events