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

Forge UI not defined

Sevigne_ Alexandru-Mihai
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 7, 2024

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:)

1 answer

1 accepted

0 votes
Answer accepted
Nikola Perisic
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 7, 2024

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.

Suggest an answer

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

Upcoming Confluence Events