top of page

How to Capture Button Click Approval in Jira Software and Update a Jira Field

How to Capture Button Click Approval in Jira Software and Update a Jira Field



Jira Software is a popular project management tool that can be used to track and manage issues, projects, and workflows. One of the features that Jira offers is the ability to add approval steps to workflows. This can be useful for ensuring that certain tasks or changes are approved by the appropriate stakeholders before they are implemented.

However, the built-in Jira workflow approval functionality does not provide a way to capture button click approval. This can be limiting, especially if you need to collect approval from users who are not Jira users or who do not have access to the Jira issue.

In this blog post, we will show you how to capture button click approval in Jira Software and update a Jira field. We will do this using a combination of a Jira plugin, a web service, and email.

Requirements

To implement this solution, you will need the following:

  • A Jira instance

  • A Jira plugin like Approvals for Jira

  • A platform for hosting your web service (e.g., AWS Lambda, Azure Functions, or a web server)

  • An email sending system

Steps

  1. Create a custom approval workflow in Approvals for Jira. This workflow will be responsible for updating the Jira field when the button is clicked.

  2. Create a web service that will be triggered by the button click. This web service will use the Jira REST API to update the Jira field.

  3. Configure the button in your email sending system to point to your web service.

  4. Send the email to the desired recipient.

  5. When the recipient clicks the button, the web service will be triggered and the Jira field will be updated.

Example

Here is an example of how to implement this solution using Express.js (Node.js) and the Jira REST API:


const express = require('express');

const fetch = require('node-fetch');

const app = express();


const PORT = 3000; // You can choose another port if desired


app.get('/approve', async (req, res) => {

const issueId = req.query.issueId;

const token = req.query.token;


// Verify token and other security measures here


try {

await updateJiraIssue(issueId);

res.send('Approval recorded!');

} catch (err) {

res.status(500).send('Error updating Jira issue.');

}

});


app.listen(PORT, () => {

console.log(`Server is running on http://localhost:${PORT}`);

});


async function updateJiraIssue(issueId) {

const jiraApiUrl = `https://your-jira-instance.atlassian.net/rest/api/2/issue/${issueId}`;

const jiraToken = 'YOUR_JIRA_API_TOKEN'; // Keep this secure!


const response = await fetch(jiraApiUrl, {

method: 'PUT',

headers: {

'Authorization': `Bearer ${jiraToken}`,

'Content-Type': 'application/json'

},

body: JSON.stringify({

fields: {

customfield_XXXXX: 'Approved' // Replace with your actual field ID and value

}

})

});


if (!response.ok) {

throw new Error('Failed to update Jira');

}

}



Conclusion

By following the steps in this blog post, you can easily capture button click approval in Jira Software and update a Jira field. This solution can be useful for a variety of use cases, such as collecting approval from customers or stakeholders, or approving changes to Jira issues.

17 views0 comments

Comentarios

Obtuvo 0 de 5 estrellas.
Aún no hay calificaciones

Agrega una calificación
bottom of page