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.
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 nowOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.