Goal: I want a scheduled automation to remove inactive users as watchers from issues.
I can identify the affected issues with the JQL: "watcher in inactiveUsers()".
Within "Global automation / Rule Builder" I can select the "Manage Watchers" action, where I can define the users, which should get removed as watchers. Unfortunately, inactiveUsers() is not available and it does not list any inactive users there at all. Only active users and apps can be chosen.
Do you have any idea/solution how to automate the removal of inactive users as watchers?
Please note: It is not an option to activate a user, remove as watcher, and then deactivate again.
Thank you!
All, I was able to solve it. See here
Would you please explain how that works?
There is no Lookup Issues action in your rule, and so {{lookupIssues}} is null, and so the entire expression is null...meaning it cannot remove any watchers.
Thanks, and kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bill,
I made some further adjustments and missed to insert the right data/screen before.
So I`ve decided to follow a two step approach.
1. step/rule (the easy rule)
My scheduled JQL "watcher in inactiveUsers() AND watchers = 1" gives me list of issues where I can simply use the "remove all existing watchers" flag.
This rule works fine. At the beginning it runs every month but in future it might be enough the run it once per quarter.
2. step/rule (for issues with more then 1 watcher)
My scheduled JQL here is "watcher in inactiveUsers() AND watchers > 1".
My lookup checks for issues where the watchers.active value is set to "false". Then I use a smart value to remove the users as watchers.
The rule removes watchers without errors but it does not limit the list of watchers to the inactive users = it removes also active users.
Note:
I`ve also tried it with this lookup:
and with changing the content within "Remove watchers", but then it generates different error messages depending on my test changes. E.g.
- Field '5e9d82c24e1a4b0c136ea646' does not exist or you do not have permission to view it
- Error in the JQL Query: A field name cannot be empty.
Maybe you have a suggestion how to proceed with my second rule/approach?
Thank you in advanced!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You found the correct field, watchers and its attribute active, and to do what you ask adjustments are needed because looking at watchers is a separate REST API call out of the rule to capture the value of active for filtering.
How that works...
Please note well: this rule uses a branch over multiple things, and so the loops run in parallel and asynchronously. Test this rule to confirm it works as you expect as it will be potentially be making multiple updates to the watchers for each issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bill,
thank you for the detailed response! My updated rule ran successfully, but first it did not remove any inactive users.
Within the "manage watcher" action I replaced {{varWatcherAccountId}} with {{varInactiveWatcher}} and since then it removes the inactive users.
You were are a great help. Thank you very much for your support!
Best regards
Andreas
Summarizing the final rule for reference:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oops...my typo! I corrected my posted answer based on what you found. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
First thing, I have not tried what you ask, although I believe it would be possible in a rule...
The {{issue.watchers}} smart value as an {{active}} attribute for each watcher. And so you could check for a value of false and remove them: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-users/
Your rule's trigger is detecting the issues with users to remove from watchers, and it could then use an advanced branch over the watchers field values, use a condition to check if they are inactive, and then remove them.
Please note: there seems to be a small delay for Jira Cloud before the attribute indicates false for an inactive user. And so I would not try to run this rule immediately after inactivating a user.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your idea Bill. I`ve tried it with different variants but had no luck so far. Getting always an error when it runs.
Note: I`ve scheduled it to run monthly over the weekend to avoid any issues with the delay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For what you have tried, please post an image of your complete automation rule, images of any relevant actions / conditions / branches, an image of the audit log details showing the rule execution, and explain what is not working as expected. Those will provide context for the community to offer ideas. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.