Forums

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

Is there any script to remove the inactive users from the watchers

srikanth kocherlakota March 7, 2022

How to remove the inactive users from the watchers using groovy ?

2 answers

0 votes
srikanth kocherlakota May 30, 2022

@Nic Brough -Adaptavist- , can you please help on this request.

0 votes
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 7, 2022

Probably.  What are you using to run scripts?

srikanth kocherlakota March 9, 2022

@Nic Brough -Adaptavist- , We are using the scriptrunner plugin addon in jira. Can we accomplish using this addon ?

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 9, 2022

Definitely can do that with Scriptrunner.

Pseudocode would be

  • Iterate through affected issues
    • read watchers and iterate over contents
      • if user is active, add them to a temporary list
    • write list back to watchers 
    • clear list out for next issue
srikanth kocherlakota March 9, 2022

@Nic Brough -Adaptavist-  Is it possible to provide the full code  ?

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 9, 2022

It's not something I've ever thought to do before, inactive watchers don't cause problems, so I don't have any code to hand.

Take a look in https://library.adaptavist.com - there's a load of scripts in there, some of which work with watchers and others with (inactive) users.

srikanth kocherlakota March 9, 2022

Hi Nic,

I have gone through this before, i have look the similar script 

A console script for removing inactive users from the board administrators. but i am looking for the inactive users from the watchers list

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 30, 2022

The code in there should show you how to identify inactive users, so the next step would be to decide how you're going to iterate - by issue or user (i.e. do you read a list of issues where watchers is not empty and then check each user in the watchers list, removing them if needed.  Or do you read the list of users, then search for issues with each inactive user named?)

Suggest an answer

Log in or Sign up to answer