Bitbucket modules
Common modules
Compass modules
Confluence modules
Jira modules
Jira Service Management modules
Rovo modules (Preview)

Jira issue view background script

The jira:issueViewBackgroundScript module adds an invisible container to the Issue view page.

This makes it the perfect candidate for:

  • distributing shared data
  • making heavy calculations
  • running code without UI elements

Examples

Because modules might be rendered in a different order, you should handle both scenarios.

Custom UI

Use the events API for communication between an issue view background script and an issue panel.

Issue view background script:

1
2
import { events } from '@forge/bridge';

// Emit the data to an already rendered issue panel
events.emit('app.data-change', 'initial-data');

// Listen to data change requests from issue panels
events.on('app.request-data', (payload) => {
  events.emit('app.data-change', 'initial-or-changed-data');
});

Issue panel:

1
2
import { events } from '@forge/bridge';

// Request data in case the background script is already rendered
events.emit('app.request-data');

// Listen to data change
events.on('app.data-change', (payload) => {
  console.log('The data has changed:', payload)
});

Manifest

1
2
modules:
  jira:issueViewBackgroundScript:
    - key: background-t-issue-view-background-script
      resource: issueBgScriptResource
  jira:issuePanel:
    - key: issue-background-dashboard-background-script-panel
      title: issue-panel
      viewportSize: medium
      icon: https://developer.atlassian.com/platform/forge/images/issue-panel-icon.svg
      resource: panelResource

Properties

PropertyTypeRequiredDescription
key

string

YesA key for the module, which other modules can refer to. Must be unique within the manifest.

Regex: ^[a-zA-Z0-9_-]+$

resourcestringRequired if using custom UI or the latest version of UI Kit.A reference to the static resources entry that your context menu app wants to display. See resources for more details.
resolver{ function: string } or
{ endpoint: string }
Yes

Set the function property if you are using a hosted function module for your resolver.

Set the endpoint property if you are using Forge remote to integrate with a remote back end.

Extension context

PropertyTypeDescription
typestringThe type of the module.
issue.idstringThe ID of the issue on which the module is rendered.
issue.keystringThe key of the issue on which the module is rendered.
issue.typestringThe type of the issue on which the module is rendered.
issue.typeIdstringThe ID of the type of the issue on which the module is rendered.
project.idstringThe ID of the project where the module is rendered.
project.keystringThe key of the project where the module is rendered.
project.typestringThe type of the project where the module is rendered.

Events

Apps can receive a frontend event that will notify your app that an issue has been changed. This event is triggered when an issue is updated or commented on. This event is only available for Jira issue view modules.

1
2
import {events} from '@forge/bridge';
    events.on('JIRA_ISSUE_CHANGED', (data) => {
    console.log('JIRA_ISSUE_CHANGED (Forge)', data);
});

However, if you have multiple issue view modules in your app, you should use the Jira issue view background script module or its Connect counterpart. This will give you a central place for fetching issue details, thus reducing the number of network requests and improving the user experience. Fetching issue details separately for every module would introduce unnecessary overhead and degrade performance.

Data shape

1
2
{
    "issueId": string,
    "projectId": string,
    "changes":[{
        "changeType": "updated" | "commented",
        "atlassianId": string
    }]
}
PropertyDescription
issueIdID of the issue the app is rendered on.
projectIdID of the project the issue belongs to.
changesList of issue changes
  • changeType - type of the change
    • commented - a comment has been added to the page
    • updated - the issue has been updated
  • atlassianId - ID of the user who made the change

Limitations

  • UI Kit apps don’t have an event system in place and so aren’t supported.
  • There is a delay between the moment the issue is modified and when the event is emitted. It might take up to a few seconds.
  • We can’t guarantee that all issue change events will be received by Jira. Therefore, the issue view may sometimes remain stale.
  • When the issue is modified by the user who is currently viewing it, it will not be refreshed. This is because we assume the change was made by that same user and there is no need for an update.

Rate this page: