July 28, 2023

Jira: Quick Update Epic Link(s)

Post is currently in DRAFT. This post explains how you can quickly link issues in Jira to an Epic using an AutoHotkey script.

Problem description

When setting an Epic Link to an Issue in Jira, the UI does not restrict the Epic selection to Epic in the same project as the issue.
Moreover, Epics are globally visible (this isn't a bug) so that you might select the wrong Epic i.e. from another project.

I share here a solution to quickly set an Epic to Jira issues (yes this works also with multiple issues selected!) based on AutoHotkey and the Jira REST API.


Solution

Get List of Epics

The List is restricted to the Epics in the same project as the source Issue and also with an Empty resolution.
You can get them using following Jql :
sJql := "project = " . RegExReplace(IssueKey,"-.*") . " and issuetype = Epic and resolution is EMPTY"
and the following REST API Request: 
JiraRootUrl . "/rest/api/2/search?jql=" . sJql

Display Epics in ListView GUI

To display the list of epics in a ListView GUI with a search functionality a bit more work is needed.

I make use a the function already presented here: AutoHotkey: Dynamic ListView and Variadic Argument | Thierry Dalon's Blog

The final function to select an Epic to link to an Issue looks like this:

Update Epic Link via API

Get Epic Link CustomField Id

The CutomfieldId for Epic might change from Jira instances to another. So it is better to get the CustomFieldId via REST API.
(Alternatively, one could store the CustomFieldId in an .ini file)

You can use a call to rest/api/2/field and look for the id value matching the element with name= "Epic Link":

{"id": "customfield_10102","name": "Epic Link","custom": true,"orderable": true,"navigable": true,"searchable": true,"clauseNames": ["cf[10102]","Epic Link"],"schema": {"type": "any","custom": "com.pyxis.greenhopper.jira:gh-epic-link","customId": 10102}},

Set Epic Link


This requires to send a PUT Request to edit an issue api/2/issue-editIssue

See code

See also

[JSWSERVER-12016] The "Epic Link" field list Epics from all the projects instead of the current one - Create and track feature requests for Atlassian products.

No comments:

Post a Comment