Capture event when add/update comment issuepanel

I have an IssuePanel and would like within the same app in forge to capture the event of adding comment to a ticket

I try this code

events.on('JIRA_ISSUE_CHANGED', async (data) => { 
  console.log(data);
 
});

but I don’t have the data of the changed comment, I only have id of the project and the user who made the change

Thanks

Hi @AlessandroVolpato,

It seems like you’ll want to switch to listening for the jira:commented:issue event rather than issue changed. You can find detailed documentation about this event here.

If you’re using a custom event, you may need to retrieve the comments using the issue key or ID via the API and emit the comments in the payload as mentioned here.

Hi @kashsingh

i try to replace ‘JIRA_ISSUE_CHANGED’ with

‘JIRA_COMMENTED_ISSUE’
‘avi:jira:commented:issue’
‘jira:commented:issue’
‘AVI_JIRA_COMMENTED_ISSUE’

but it doesn’t work

@AlessandroVolpato It’s not as simple as that. You need to specify an event trigger in your manifest file and then link it to a handler function that will execute when the event trigger occurs. Check out this article for guidance. In the article, they demonstrate how a handler function is activated to add a comment to an issue upon its creation.

1 Like

@kashsingh

I tried to follow the article step by step but the product-triggers don’t work
the hello-word message is also not displayed on the console when the ticket is created

@AlessandroVolpato Well that is strange, would it be possible for you to share the code snippet from your App’s src/index.jsx and manifest.yml files?

@kashsingh
i create product-trigger project

and this is the default contento of index.jsx

export async function run(event, context) {
	console.log('Hello World!');
}

and this is the manifest.yml

modules:
  trigger:
    - key: test-trigger-hello-world
      function: main
      events:
        - avi:jira:created:issue
        - avi:jira:commented:issue
  function:
    - key: main
      handler: index.run
app:
  id: MYAPPID
permissions:
  scopes:
    - read:jira-work

1 Like

@AlessandroVolpato Your code appears satisfactory to me. It seems you’re expecting the output of the console log in your browser, but it should actually be visible in your terminal where you’re tunneling the application. Since your event handler runs on the remote lambda function, any console logs will be displayed in the application logs rather than on the client side (such as your browser). Refer to the image below to see the output of the same code.

1 Like

When I tried in the console after making forge tunnel nothing is displayed

I am using a macbook pro with m1 pro processor

and on jira I have free license of both jira service management and jira software I don’t know if that are a problem

I just tried again to create a new project from scratch and now it works

maybe there was a momentary problem