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.
×Hello,
I'm using Forge cli to build a confluence content action. When I press the button, a jira issue is created.
My manifest file :
modules:
confluence:contentAction:
- key: create-jira-issue
title: Create Jira Issue
function: main
icon: https://developer.atlassian.com/platform/forge/images/issue16.png
function:
- key: main
handler: index.run
app:
id: "ari:cloud:ecosystem::app/85c7e68b-a451-4169-804f-0653e2ee4459"
permissions:
scopes:
- read:confluence-content.summary
- write:jira-work
- read:confluence-content.all
My index.jsx file :
const { Fragment, Text, ContentAction } = require('@forge/ui');
const api = require('@forge/api');
const { route } = api;
async function run(context) {
console.log(context);
console.log(context.context);
console.log("Page ID: " + context.context.contentId);
const pageId = context.context.contentId;
const response = await api.asApp().requestConfluence(route`/wiki/rest/api/content/${pageId}`,{
headers: {
'Accept': 'application/json'
}
});
if (!response.ok) {
console.log(await response.text());
throw new Error(`Error fetching Confluence page: ${response.status} ${response.statusText}`);
}
let page;
try {
page = await response.json();
} catch (error) {
console.error('Error parsing JSON:', error);
}
const pageTitle = page.title;
console.log("Page Title: " + pageTitle);
const jiraResponse = await api.asApp().requestJira(route`/rest/api/2/issue`, {
method: 'POST',
body: JSON.stringify({
fields: {
project: {
key: 'JCI'
},
summary: `Issue created from Confluence page: ${pageTitle}`,
issuetype: {
name: 'Task'
},
}
})
});
if (!jiraResponse.ok) {
throw new Error(`Error creating Jira issue: ${jiraResponse.status} ${jiraResponse.statusText}`);
}
return (
<ContentAction>
<Fragment>
<Text content={'Jira issue created successfully from Confluence page: ' + pageTitle} />
</Fragment>
</ContentAction>
);
}
module.exports = {
run,
};
When i press the button, i have the following error in the confluence ui :
Trace ID: 6d13d3734c3f4d719b9d5628b22b952d There was an error invoking the function - ForgeUI is not defined
ReferenceError: ForgeUI is not defined at run (index.js:25669:3)
Any idea of how to fix this?
Thank you:)
Hello @Sevigne_ Alexandru-Mihai
From the docs, I found this one useful: https://community.developer.atlassian.com/t/cant-get-my-simple-forgeui-app-running-in-jira-cloud-deploy-fails/51273/9
Scroll down for the MatteoGubelliniSoftC comment where he mentions the Forge UI to be imported.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.