Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

ShowFlag in Post Function Forge App

TMonatisa March 17, 2025

Hi 

 

import { showFlag } from '@forge/bridge';

export const postfunction = ({ issue, transition: { from, to }, configuration: {message} }) => {
console.log(`PostFunction for issue ${issue.key} for transition from status ${from.id} to ${to.id} with config message: ${message}`);
const flag = showFlag({
id: 'success-flag',
title: 'Hello World!',
type: 'info',
description: 'Here is a flag body description.',
actions: [
{
text: 'Flag action',
onClick: () => {
console.log('flag action clicked');
},
}
],
isAutoDismiss: true,
});

flag.close();
};

 

 

 

I am developing a Forge app that displays a message when an issue transitions to another status. While I can see the message in the console when using console.log, I am unable to display it using ShowFlag.

Since this is a Custom UI app, could you assist me in ensuring the message appears correctly? Any guidance would be greatly appreciated.

Kind regards

Tiisetso Monatisa

2 answers

1 accepted

0 votes
Answer accepted
Tim Pettersen
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 17, 2025

Hi @TMonatisa

The `showFlag` function is only supported on the client-side, whereas post-functions are evaluated on the backend. You can't use it directly in a post-function module.

However, you can workaround this by using an `issueViewBackgroundScript` module to use the `showFlag` function instead.

I created a little example app that uses this technique last week for another customer: https://github.com/kannonboy/forge-toaster

It allows an admin to create a message targeting a specific user which is then displayed as a flag the next time they view an issue or a dashboard in Jira. At the moment it does this via an `adminPage`, but you could adapt it to create the message from a post-function instead.

cheers,

Tim

TMonatisa March 18, 2025

Hi Tim

Thank you. I will use the workaround.

 

0 votes
ELFAPP Technologies
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 17, 2025

Hi @TMonatisa 

 

That's the same example in the documentation minus being nested with an export function. Probably you should not include the showFlag object inside an export function.

TMonatisa March 17, 2025

Hi @ELFAPP Technologies 

So where should I call the showFlag if not in the export function?

ELFAPP Technologies
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 17, 2025

I think for you to use it the way you want, you most probably want to return showFlag then you can include it in the export function. For example

import { showFlag } from '@forge/bridge';


const flag = () => {
return showFlag({
id: 'success-flag',
title: 'Hello World!',
type: 'info',
description: 'Here is a flag body description.',
actions: [
{
text: 'Flag action',
onClick: () => {
console.log('flag action clicked');
},
}
],
isAutoDismiss: true,
});
}

export const postfunction = ({ issue, transition: { from, to },
configuration: {message} }) => {
console.log(`PostFunction for issue ${issue.key}
for transition from status
${from.id} to ${to.id}
with config message:
${message}`);

flag().close();

};

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events