Hello All,
I want remove to users from the parent watchers fields when his/her sub-tasks completed.
Is it possible?
Thanks in advance,
Manikanta
Hi @Mani,
you are almost there, your current script is running for the issue on which event(transition) is happened. you just need to get it's parent object
I'm attaching updated script for your reference
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.MutableIssueimport com.atlassian.jira.user.ApplicationUserdef userManager = ComponentAccessor.getUserManager()def watcherManager = ComponentAccessor.getWatcherManager()if(issue.getIssueType().name == "Sub-task"){ //used to check sub-task or not if workflow is same if not you can remove this condition def parent = issue.getParentObject() // getting parent object ApplicationUser user = issue.getAssignee() // getting sub-tasks assignee watcherManager.stopWatching(user, parent) // remove sub-task assignee from parent's watcher list}
NOTE: I'm just removing Done sub-tasks assignee from parent's watcher list not all
Hope it helps you
BR,Leo
Hello @Mani ,
with the default features of the postfunction in the workflows, i am not 100% sure that you can achieve it. However, if you have scriptrunner addon installed you could implement a simple script to do this functionallity.
This link below may help you, as a guide:
https://community.atlassian.com/t5/Jira-questions/scriptrunner-how-to-clear-watchers-when-creating-subtask/qaq-p/117538
RegardsChristos
Hi @Christos Moysiadis
I placed below script in the sub-task Done transition, but it is removing watchers from the sub-task issues, i want to remove watchers from the parent issue type.
import com.atlassian.jira.component.ComponentAccessor def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() def locale = ComponentAccessor.getLocaleManager().getLocaleFor(user) def watcherManager = ComponentAccessor.getWatcherManager() def watchers = watcherManager.getWatchers(issue, locale) watchers.each { watcher ->; watcherManager.stopWatching(watcher, issue) }
For Example - 3 sub-tasks are assigned on my name once all sub-tasks are moved to Done, my name should not be there on the parent watcher list.
Hi @Leo ,
Thanks for the script.
sub-task watcher is getting removed once one of the sub-task is moved to Done. But in my case assignee should be removed from the watcher field only if all sub-tasks moved to Done assigned on his/her name.
Mani
It's little tricky, we need to iterate over all sub-tasks of parent and check the status and assignee of each, I just modified something in above script. mostly this should do the job for you
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.MutableIssueimport com.atlassian.jira.user.ApplicationUserdef userManager = ComponentAccessor.getUserManager()def watcherManager = ComponentAccessor.getWatcherManager()if(issue.getIssueType().name == "Sub-task"){ def allDone = true ApplicationUser user = issue.getAssignee() def parent = issue.getParentObject() parent.getSubTaskObjects()?.each { subtask -> if(subtask.getAssignee() == user && subtask.getStatus().name != "Done" && subtask != issue) { allDone = false } } if(allDone){ watcherManager.stopWatching(user, parent) } }
BR,
Leo
Thanks a lot, It worked.
It looks like you're new here. Sign in or register to get started.