Hello , I want a solution to restrict the creation of subtasks per issue type.
I tried to create a forge app but nothing changes. here is my manifest.yml:
modules:
trigger:
- key: issue-subtask-hello-world
function: main
events:
- jira:issue_created
function:
- key: main
handler: index.run
app:
runtime:
name: nodejs18.x
id: ari:cloud:ecosystem::app/0aeac7b4-4bf2-4d2b-a6a3-1cfc22bd81b3
and index.jsx :
export async function run(event, context) {
console.log('Trigger Event:', event);
const issue = event.issue;
const parentIssueId = issue.fields.parent?.id;
if (parentIssueId) {
try {
// Fetch parent issue details
const response = await fetch(`/rest/api/3/issue/${parentIssueId}`);
const parentIssue = await response.json();
const allowedIssueTypes = ['Story', 'Task'];
if (!allowedIssueTypes.includes(parentIssue.fields.issuetype.name)) {
await fetch(`/rest/api/3/issue/${issue.id}`, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json'
}
});
console.log(`Subtask ${issue.key} deleted because its parent issue type is not allowed.`);
}
} catch (error) {
console.error('Error handling issue:', error);
}
} else {
console.log(`No parent issue found for ${issue.key}.`);
}}
If there is another solution please let me know.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.