Hi Friends!
There is a way to transition parent when all sub-tasks change the status.
But is it a way to transition parent issue when simple checkbox field with one value are marked in all sub-tasks?
In other words I need to transition parent issue when the checkbox customfield in the last sub-task was updated.
Hi friend,
Actually the fast track is not an option for you because this will fast track the issue where the update happen, so in your case the subtask.
You want a custom listener where will listens for Issue Updated events and if the updated issue is a subtask then it should go to the parent, get all it's subtasks and if all of them have selected at least the value you want then it will transit the parent.
Therefore you custom listener, that listens for an Issue Updated event and for the project/s you want. Now, your script (and for a JIRA v7) will be
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.IssueInputParameters import com.atlassian.jira.user.ApplicationUser import com.atlassian.jira.workflow.TransitionOptions def change = event?.getChangeLog()?.getRelated("ChildChangeItem").find {it.field == "CheckBox A"} if (! change) { // there was an update issue update but it was not the checkbox therefore do nothing return } Issue issue = issue def flag = true def ACTION_ID = 21 // replace with the action id that you want to transit the parent // is not a subtask therefore do nothing if (! issue.isSubTask()) return def cwdUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() // iterate over the subtasks if at least on of the subtasks has notn the value 'Yes' checked then return false issue.getParentObject().subTaskObjects?.each {subtask -> def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("CheckBox A") def cfValue = subtask.getCustomFieldValue(cf) if (! ("Yes" in cfValue*.value) || !cfValue) { log.debug ("Yes option is not selected for subtask ${subtask.key} or there is no option at all") flag = false } } // it it reaches here means all the subtasks have selected ONLY the value yes for the custom field CheckBox A if (flag) transitIssue(issue.parentObject, ACTION_ID, cwdUser) // this means that all the subtasks have the value 'Yes' checked, therefore return true and make the transition def transitIssue(Issue issue, int actionId, ApplicationUser cwdUser) { def issueService = ComponentAccessor.getIssueService() IssueInputParameters issueInputParameters = issueService.newIssueInputParameters() issueInputParameters.setSkipScreenCheck(true) def transitionOptions= new TransitionOptions.Builder() .skipConditions() .skipPermissions() .skipValidators() .build() def transitionValidationResult = issueService.validateTransition(cwdUser, issue.id, actionId, issueInputParameters, transitionOptions) if (transitionValidationResult.isValid()) { return issueService.transition(cwdUser, transitionValidationResult).getIssue() } log.error "Transition of issue ${issue.key} failed. " + transitionValidationResult.errorCollection }
For you information the checkboxes can have more than one value. So in the script above will check if at least on of the selected values (for each subtask) is Yes then it will transit the parent.
Hope that helps.
Regards, Thanos
Hi Thanos!
I still was not able to completely check your great script. Moreover I found a workaround by using of Automation wich allows to transit an issue automaticly by checking a checkbox and then I use post-function from my description.
But I have marked your reply as an answer because I think it will work and someone can use it in the future!
Thanks
See you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You would need to write a customer listener using script runner for doing that.
Check here for some examples: https://scriptrunner.adaptavist.com/4.3.5/jira/listeners.html
-Ravi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ravi. Thanks for the answer!
So I think I should use Fast-track transition an issue listener.
In this case what do I need to choose as event when sub-task is updated?
Which condition helps me to check that all e.g. customfields_10800 have checkboxes?
Sorry I am not good at script writing
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline 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.