Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get first component of a Jira issue?

Sam
Contributor
February 8, 2021

Is there a way to query the DB of a Jira Service Management instance to get the first component of any given issue?

1 answer

0 votes
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 8, 2021

What do you mean by "first"?  Components do not have any real order, they're an unordered set.

Standard recommendation here is to not be reading the database here (it's a mess, totally unsuitable for reporting) and look to using REST calls instead.

But if you must do it this way, you'll need to join jiraissue to nodeassociation, select for component link and then look to component to see the detail of the component(s).  This will at least give you the list of components on an issue.

Sam
Contributor
February 10, 2021

Hi Nic, thank you for your response; I agree that querying the database is too unreliable. Do you know of a better way to get this information? We have ScriptRunner, if that helps.

In this Jira instance, every issue is given one component on creation. However, there's a chance that it was changed to something else; it might have gone from one component to another or have additional components. What I'm trying to figure out is how to get this information for each component in the project.

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 27, 2021

Sorry for the delay, this one slipped past me.

You'll want to read the change history for the issue, if that has any "component changed" lines in it, they will record the from and to, so you can read the earliest one of them for the "from".  If there are no lines in the history for component change, then you know that the issue currently has the original component.

A single REST call to read an issue will return the whole thing in JSON which is easy to parse for the history and current component.

Suggest an answer

Log in or Sign up to answer