Refresh jira:issueContext when users changes workflow


recently my company decided to investigate forge and its features. I have been creating a new plugin for some time now and so far it was a good experience. Sadly I encountered an issue I am not sure how to tackle.

My use case is:

  1. A user opens an issue
  2. Plugin jira:issueContext shows up in the sidebar with some data
  3. User moves the issue to in-progress
  4. A jira:workflowPostFunction is triggered and creates some data

What I want to do now is to refresh the panel, but I can’t find a way to do it. I tried
events.emit('TEST_EVENT', "EMPTY"); But it seems it doesn’t work when triggered by workflowPostFunction.

Do you know any way to achieve that?

Hi @KamilParzyjaga ,

My understanding is that you want to re-render your app’s jira:issueContext UI after your app’s jira:workflowPostFunction is triggered and performs some operation, presumably on the issue. Let me know if my understanding is not correct.

The events.emit API only works in app front ends implemented with Custom UI. It’s designed to allow your app’s front end components to talk to each other. The jira:workflowPostFunction extension results in the execution of one of your app’s backend functions (ignoring the front end configuration aspects of workflow post functions).

Jira will refresh the issue view under certain circumstances, mainly when another user updates the issue. On the assumption your operation is some action on the issue, then you’ll want to call the Jira REST API from your workflow post function. Within the jira:workflowPostFunction invocation, I believe your app has to invoke the Jira REST API using api.asApp() rather than api.asUser() due to the lack of user context, which means the user that acts on the issue will not be the same as the current logged in user. So I think updates to the issue from the jira:workflowPostFunction should result in Jira refreshing the issue view. I haven’t tested this though.

If the above doesn’t work for you and your jira:issueContext is implemented in Custom UI, then it could poll against the Jira REST API to check if it needs to refresh itself, but this is not an efficient solution, will result in a lot of unnecessary invocations and delays before refreshing. As a result I wouldn’t recommend this pattern.



Hi @dmorrow

I checked, and Jira indeed fires an event when a user changes something on the UI. Below is the code I used. I am not sure if post functions are always completed before the event is emitted, but it was working for me. Below is the code I used.

import {events} from "@forge/bridge";
useEffect(() => {
  events.on('JIRA_ISSUE_CHANGED', () => {
}, []);