JQL to return limited columns

Melissa Ritts February 5, 2014

How can I create a JQL script that will return only specified columns from the view?

3 answers

1 accepted

1 vote
Answer accepted
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 5, 2014

You don't.

JQL is for *finding* issues. It has nothing to say about how you look at the information on them.

The results from JQL are a simple list of issues, which you then give to a display function. The display function then decides what and how to display it. The issue navigator is one function, each gadget is a different display function, reports are more, and so-on.

I suspect what you want is a "saved filter", because you can save a set of columns with such a filter. This is nothing to do with the JQL, it's done by the issue navigator, and only the issue navigator and excel output will use the saved columns (handing the columns to most other functions is complete nonsense), but I think that's what you're looking for.

Melissa Ritts February 23, 2014

Thank you Nic. I appreciate it.

Richard Cross February 1, 2017

It's a reasonable question though, as other notable query languages (such as SQL) do not simply retrieve data but also allow modification of the output in a convenient format.

Like # people like this
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 1, 2017

Yup, that's why I have a canned response for these questions - people assume equivalence from similarity, which is perfectly natural and instinctive, no matter how wrong.

Like # people like this
Perry Tancredi July 17, 2019

It seems things may have changed since Nic's answer many years ago (see Mark Mann's answer below). 

Like Jeremy Royster likes this
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 28, 2019

No, they've not changed.  The REST API simply replicates what you can do in one of the many ways you can ask the issue navigator to behave.

Perry Tancredi August 10, 2020

Thanks, Nic

10 votes
Mark Mann September 27, 2017

https://docs.atlassian.com/jira/REST/server/#api/2/search-searchUsingSearchRequest shows a way to limit the fields that come back from a search.  You can supply both the JQL to find your matching issues as well as a list of fields (and start date and limit the results to some maximum number).

Perry Tancredi July 17, 2019

Thanks, this is the real answer

Like # people like this
John M October 31, 2020

No such option for Cloud, is there?

xtb28twq December 3, 2020

Thanks for your thoughtful, non-canned reply, Mark.  This is my exact use case.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 3, 2020

Strictly speaking, it's the wrong answer.

The question was "JQL to return a chosen set of columns".   Using the REST API is not using JQL to define the set of columns.  It's using the reporting on a JQL result set to get the columns you want.  Like most of the other ways of reporting on a JQL result set, the choice of output is made by the reporting system, not the JQL.

So while it's technically wrong, it still does what you need.  As does the issue navigator, export, download and and and.

Like Tom McCutchen likes this
0 votes
Héctor Lira July 31, 2017

You can use the following code:

function main() {
   return Events({
      from_date: 'YYYY-mm-dd',
      to_date: 'YYYY-mm-dd',
      event_selectors: [
         {event: 'event1'},
         {event: 'event2'}
      ]
})
   .map(function(event){
      return {
         'distinct_id':event.distinct_id,
         'Event_name':event.name,
         'Event_time':event.time
      };
   });
}

 

This will extract specific events (event1, event2: such as 'Visit' or 'App Opened') that occured in specific dates (from_date, to_date) and will retrieve only the columns specified after the .map step. You can also use 'new Date(event.time)' instead of only retrieving event.time to get a date format for the time of the event.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 31, 2017

No, that's utterly wrong.  Please re-read the first two lines of the answer.

rajanibs November 28, 2019

Answer given is for REST API queries and not the JQL.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 28, 2019

Exactly, that's why I suggested reading the answer.

Suggest an answer

Log in or Sign up to answer