Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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 Champion
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
atlassian, team '25 europe, atlassian event, barcelona 2025, jira, confluence, atlassian intelligence, rovo, ai-powered collaboration, developer tools, agile teams, digital transformation, teamwork solutions, atlassian conference, product announcements

🌆 Team '25 Europe registration is now open!

Join the largest European gathering of the Atlassian Community and reimagine what’s possible when great teams and transformative technology come together. Plus, grab your Super Fan ticket now and save over €1,000 on your pass before prices rise on 3 June.

Register now
AUG Leaders

Atlassian Community Events