Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

stopWatching in Escalation service

Renni Verho
Contributor
July 16, 2019

Hi, 

 

Could some one help me with escalation service automation ? I have tried to add stopWatching functionality for issues which are handled with escalation service, but no success yet. 

code part from latest trial: 

def watcherManager = ComponentAccessor.getWatcherManager()
def userManager = ComponentAccessor.getUserManager()
def user = userManager.getUserByKey("<As User userid>")
watcherManager.stopWatching(user, issue)

 

what may be wrong in here ? 

 

1 answer

1 accepted

0 votes
Answer accepted
Antoine Berry
Community Champion
July 17, 2019

Hi @Renni Verho ,

This seems correct ! I suspect the user may not retrieved correctly though, may you please add this line to check if this is the case : 

log.error("user : " + user)

and then look at the logs ?

Antoine

Renni Verho
Contributor
July 18, 2019

There may be a bug. by some reason format is  username(username) - I assume user should be username just once. 

Renni Verho
Contributor
July 18, 2019

no checked similar transition script and it works correctly with similar user information. 

Antoine Berry
Community Champion
July 18, 2019

So the script is working sometimes ?

You should check the logs when it is not working. Also make sure the user you are triggering the post function with has enough rights to manage watchers.

Antoine

Renni Verho
Contributor
July 18, 2019

Tested script with another users and it woks ok.

 

Problem is only for user in "As User" field, it cannot be removed inside escalation script. 

Any ideas how to remove runner user from watcher list ? 

Antoine Berry
Community Champion
July 18, 2019

What I mean is the user running the script should have enough rights in the project permissions : 

image.png

image.png

If you want to remove the currently logged in user from the watcher, use this instead : 

def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
Renni Verho
Contributor
July 18, 2019

User running the script have enough rights and stopWatching in Escalation service looks working ok. 

Found out that problem is due Autowatch function running order in Jira.  We use "Inherit from global settings" for autowatch in user profile and Default user preference is yes.

That means removing "As User" person in script does not work, because autowatch adds user after script end.

Verified theory by changing Autowatch to Disabled for "As User" user and watch setting  stays clean. 

 

Next step may be to find workaround how to turn autowatch off during script running or something like that. 

Antoine Berry
Community Champion
July 18, 2019

I see, that makes sense. Good job finding out. :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events