HAPI Examples
Explore practical HAPI script examples for common Jira tasks, ready to adapt for your own instance.
- Automatically add users to linked issues as watchers
- Calculate the impact of an issue based on the number of linked support cases
- Automatically add reviewers based on the issue request type
Automatically add users to linked issues as watchers
Scenario
When a support request is raised, other issues are sometimes linked to the support request issue because they cause the support request. Great Adventure wants the reporter of the initial support request, and request participants, to be automatically added as watchers to the linked issues that cause the raised issue.
With this automation, Great Adventure can ensure people are informed of linked issues and subsequently progress.
Solution
Create a custom listener and use HAPI.
With HAPI, we've made it easy for you to Work with Issue Links, Users, and Watchers. This means the script for the following use case has fewer imports, is much shorter, and is easier to adapt to your own instance if desired.
Steps
Test
You can now test this example by linking one issue to another using causes or is caused by link type. The reporter, and if applicable, request participants, are added as watchers to the issue that causes the linked issue.
Calculate the impact of an issue based on the number of linked support cases
Scenario
Great Adventure wants to calculate the impact of an issue based on the number of customer support cases that have been linked to it.
With this automation, Great Adventure can monitor the impact of certain issues and use JQL search to easily identify high impact issues.
Solution
Create a custom script field and use HAPI to count the number of causes links an issue has.
With HAPI, we've made it easy for you to Work with Issue Links. This means the script for the following use case is much simpler and easy to adapt to your own instance if desired.
Steps
Test
You can check this example works by going to a given issue that this custom field is configured to.
You can also easily find all issues with a given impact using the following JQL search:
Impact ~ "Critical Impact"Automatically add reviewers based on the issue request type
Scenario
Great adventure wants reviewers to be set automatically depending on the issue request type. For example, purchases over 100 dollars need to be cleared by the accounts department, and any travel requests need to be cleared by your manager.
With this automation, Great Adventure can stay aligned with their internal auditing and governance rules.
Solution
Create a custom workflow function and use HAPI.
With HAPI, we've made it easy for you to Update Issues from a workflow function. This means the script for the following use case is much simpler and easy to adapt to your own instance if desired.
Steps
Test
You can check this example works by raising a request a checking that the approvals have been added.