HAPI Examples
To help you get started using HAPI effectively in your Jira instance, we have provided several use cases/examples below that incorporate HAPI in the scripts. You can use these examples to explore and customize your Jira instance.
Update parent with subtask count
As an engineer working on larger tasks, it is better for tracking and delegation purposes to have these broken down into multiple subtasks. To have an accurate overview, it's crucial to know how many subtasks a parent work item has. Whenever a new subtask is created, updated, or deleted, the parent work item should reflect the current count of its subtasks.
HAPI solution
Create a custom listener and use HAPI.
This script automates the task of updating the parent work item with the number count of its subtasks, removing the need to manually check and update it every time.
With HAPI, we've made it easy for you to update work items. 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.
Test
To verify this script:
- Create a Subtask: Add a new subtask to any of your work items in Jira.
- Ensure Field Exists: Confirm that you have a numerical custom field named Subtask Count in your Jira instance. If the field has a different name, update the script accordingly before testing.
Your parent ticket will be updated with the subtask Count.
Add a comment on the work item created
When a support ticket is raised, we often want to automatically add a comment to the work item, thanking the reporter and providing helpful information such as response timelines, documentation links, and work timings. This ensures better communication and sets clear expectations for the reporter.
HAPI solution
Create a custom listener and use HAPI.
This script demonstrates how to automatically add a comment to a newly created work item in Jira, improving communication by providing relevant information right away. Using HAPI, Update Work Items (Update Issues) has been made simple and efficient.
Test
To test this script, you need to create a new ticket, and it will automatically be updated with the added comment.
Bulk update multiple work item resolutions
As a Jira admin, I want to change the resolution of a large number of work items that were mislabelled. I can use this script to update the resolution of all these issues to their corresponding one ("Duplicate").
HAPI solution
Run this HAPI script using the Script Console.
This script automates the process of bulk updating the resolution of all issues returned from the JQL search that meet the specified conditions.
Test
The script updates the resolution of the work item.
Add or update the link for a work item in Jira Cloud
As a Jira admin, I want to bulk link work items to keep track of my related work for one of my spaces. I can do this quickly and efficiently with this script.
HAPI solution
Run this HAPI script using the Script Console.
Linking issues means you can create an association between two existing work items. With this script, you can bulk link a set of work items.
Test
How to create a new script video demo
Watch the following video demo to learn how to create a new script.