How to use Class 'IssueWatcherAddedEvent' in Forge App ✉ (Custom Events, Webhooks, Web triggers)

Hi, Folks!
I’m starting to use Forge and after a couple of the days searching it seems your appreciate help is required.

There is the event
IssueWatcherAddedEvent (Atlassian JIRA 7.6.1 API)

How can I integrate it in Forge App?
I need to do something when Watchers list was updated.

In Forge documentation I found the list of events, but there only main ones:
Jira events (atlassian.com)

Thanks in advance for any hint or link!
With kind regards
Slava

1 Like

Hi everyone!
There is a way to catch this event via ScriptRunner:
Solved: Getting watcher-adder from IssueWatcherAddedEvent … (atlassian.com)
Can I use the same code within Forge?

With warm regards
Slava

This is from the link above

import com.atlassian.jira.event.issue.IssueWatcherAddedEvent
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.component.ComponentAccessor

def watcherEvent = event as IssueWatcherAddedEvent
def eventIssue = watcherEvent.getIssue() as Issue
def watcherUser = watcherEvent.getApplicationUser() as ApplicationUser
def watcherManager = ComponentAccessor.getWatcherManager()

// make this point to a directory group to de-jank and open up
def immuneUsers = ["meLDAP","meAdmin"]

if (immuneUsers.contains(watcherUser.getName())) {
 watcherManager.stopWatching(watcherUser, eventIssue)
}

Hi @SlavaStarovoitov, thank you for reaching out.
Unfortunately, we don’t have product events for issue watchers in Forge yet (the link you provided in your first post is from Jira Server Platform).

Here is a list of currently supported Jira Product events: https://developer.atlassian.com/platform/forge/events-reference/jira/

As a workaround you can try to configure Webhook: https://developer.atlassian.com/cloud/jira/platform/webhooks/#registering-a-webhook-via-the-jira-rest-api-for-connect-apps and call Forge Web trigger https://developer.atlassian.com/platform/forge/events-reference/web-trigger/ However, I’m not sure if it suits your needs.

4 Likes

@ljarzabek many thanks for your appreciated help :pray:
As I see through the link you mentioned there is a webhook related to the Watchers

image

And seems it will help.
Can I ask later if I’ll meet some questions?

Also could you let me know if this Atlassian Jira documentation is Usable in Forge? In other words could it be helpful?

There is the event
IssueWatcherAddedEvent (Atlassian JIRA 7.6.1 API)

Feel free to reach out within this or new thread. Regarding documentation, please refer to pages in Jira Cloud Platform: https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/ - as I mentioned, page you had provided link is from Jira Server Platform and Forge is specifically made for a Cloud.

:hugs:

I found this here:

This is Cloud doc, is not it?

That’s a mislabelled javadoc link. That’s server and for a Jira version that isn’t on the supported list ( Atlassian Support End of Life Policy | Atlassian Support | Atlassian Documentation )

For Jira events in Forge you’ll want to look at https://developer.atlassian.com/platform/forge/events-reference/jira/#issue-events

1 Like

Hi @ljarzabek hope you are doing well!
I went trough the link you mentioned above and found this

Handling the webhook event

To receive webhook events, your add-on needs to include the webhook module declaration in its JSON descriptor. The declaration indicates the add-on relative URL at which it will receive the notification…
Webhook (atlassian.com)

But I didn’t find any information about how to set it up. Could please provide some information or link to learn this?
In other words I know how to send webhook, but I don’t know how to catch it in Forge App.

Thank you in advance for any information that helps to do it.
With warm regards
Slava

Hi @SlavaStarovoitov,

In my very first message I also included link to Forge webtrigger: https://developer.atlassian.com/platform/forge/events-reference/web-trigger/

My idea was to setup webtrigger for you app, generate a link (as described) and configure your webhook to call it. Hope it helps.
https://developer.atlassian.com/platform/forge/manifest-reference/modules/web-trigger/

@ljarzabek great Lukasz :pray:
Due I haven’t really dived into the topic yet, I didn’t bind that links. Now I see that this is what I need!

My idea was to setup webtrigger for you app, generate a link (as described) and configure your webhook to call it. Hope it helps.

Yea, this is a great idea. I just didn’t find some technical things. Now they are.
I’ll let here know once webhook works!

Have a nice day and weekend!
With kind regards
Slava

1 Like