Add/Remove Watchers Listener
You can use the Add/Remove Watchers built-in listener to choose to add or remove watchers on spaces, blogs, or content selected by the CQL when prompted by a Confluence event.
- In Note, you can enter a note for your reference.
This note shows up on the main Listeners screen. Select some Event(s) that you'd like to listen for. The Event(s) you select triggers the change to watchers.
After you select some Event(s), the Select By field appears.Crowd events are supported.
For Condition, enter code in the Script tab or upload code in the File tab.
This code evaluates after one of your selected events is fired, and is used to determine whether or not the listener should execute.If left blank, the condition automatically evaluates to "true."
Select Show Examples to see provided conditions. Once you select one, you can paste it in the field.
For Select By, select the type of content that you'd like to work with.
Your choices are:
Space
When you select Space, the user(s) and/or group(s) are added as space watchers not page watchers.
Additionally, if you select Space and remove user(s) as watchers, they may still watch the pages in the space.
Blog
CQL
When you select CQL, the user(s) and group(s) are added as page watchers.
Additionally, if you select CQL and add user(s) as watchers to a space, they may still be space watchers.
Based on what you select in the previous step, you see one of the following:
Target Space - Enter the space you want to work with if you picked Space or Blog.
CQL Query - Enter the query you want to work with if you picked CQL.
Select Show Examples to see provided CQL queries. If you select one, the field auto-fills with the query.
The hit counter to the right of the field indicates how many results are returned by the CQL query you entered.
For Apply to Groups, select which group(s) you want to work with.
For Apply to Users, select which user(s) you want to work with.
You can select both users and groups for each set of watchers you are working with.For Action, select if you want the group(s) and/or user(s) to Watch or Unwatch.
Select Preview to view results, or select Run to apply the change.
Users are only listed in the results if they have permission to view the selected content.
If you add a user who was already watching the content, they are not listed in the results.
If you try to remove a watcher that was not watching the content, they are not listed in the results.
Example: Add New Marketing Users as Watchers for Marketing Space
In your Confluence instance, you may have groups for different departments in your organization. You may have a space for each department in your organization as well. When a new user joins the team, you may want to have them watch their department's space so they're notified of information that relates to them. Using the Add/Remove Watchers listener, you can automate this. In this example, we will set up a listener that will add any new users added to the Marketing group as watchers of the Marketing space.
Only new users added to the group then become watchers. The groups won't necessarily stay in sync.
- For Note, enter a description for your reference, like Add Marketing Watchers.
- For Event, select GroupMembershipsCreatedEvent.
For Condition, enter the following code:
groovyevent.groupName == "marketing-users"
- For Select By, choose Space.
- For Target Space, select your marketing space.
For example, Marketing. - For Apply to Groups, select your marketing group.
For example, marketing-users. - Leave Apply to Users blank.
- Select Watch for the Action.
- Select Add.