Forums

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

How can I search for issues where a label was added within a date range?

Esther Strom
Community Champion
November 12, 2019

We're looking for a way to find issues that have had a specific label added before a specific date.

I've used JQL to find changes in fields before, using queries like

 

status WAS "Resolved" BY jsmith BEFORE "2019/02/02"

But when I try to use any of the "history" functions (including WAS), I get an error saying that "History searches do not support the 'labels' field."

 

How can we do a search that will give us what we need? We do have ScriptRunner, which includes the Enhanced Search. We are on Cloud. 

4 answers

2 votes
GP
Contributor
November 13, 2019

Hi Esther,

The labels field does not currently hold an updated date or time in a manner that is accesible with JQL as history searches do not support the 'labels' field.

Please check the description of this ticket. Atlassian rejected this due to the limited demand

https://jira.atlassian.com/browse/JRASERVER-36694

Meanwhile, you can try, if this solves your problem up to a certain extent.

Sample JQL

project = "Project Name"AND labels in ("Label Name") AND updated > -1d

 

Thanks,

Gaurav

Esther Strom
Community Champion
November 13, 2019

Thank you, but I know that query will not get us what we need, because updated will get you any ticket where any of many fields were updated. We need to be able to specify specifically when the labels field was updated.

Like GP likes this
GP
Contributor
November 13, 2019

Yes totally agree with you! but history searches do not support the 'labels' field & Atlassian is not going to work on this in near future.

https://jira.atlassian.com/browse/JRASERVER-36694

 

Thanks,

Gaurav Pratap [GP]

1 vote
Paron Forge August 5, 2024

Hi @Esther Strom

At Paron Forge, we developed a gadget that helps to manage label history - Label Ledger. Just pick a label and project/filter and in the table view, you will see 3 events when the label was:

  • added during issue creation
  • added to an existing issue
  • removed from issue

Link to the marketplace

Link to our docs

1 vote
Mark Kern [SaaSJet]
Contributor
December 27, 2019

Hi @Esther Strom 

As an alternative solution, you can try Issue History.
With this app, you could select issues by Label and monitor the history of all changes that were made in issues by dates you need.

Hope it helps

0 votes
Kyle Smith
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 8, 2022

This is an old thread, but I have solved this problem with a script using the Jira API, filtering through the ticket changelog. 

def jiraDateToDaysDelta(date: str) -> int:
'''Return the delta in days between now and the date provided'''
date = date.rsplit('-', 1)[0] # Remove timezone
return (datetime.now() - datetime.fromisoformat(date)).days

def ticketHasLabelInTimeframe(ticket: JiraTicket, label: str, LOOKBACK_TIME: int) -> bool:
'''Determine if a label was added to a ticket within the lookback time'''
for update in ticket.changelog.histories:
for field in update.items:
if field.field != 'labels':
continue
if label not in field.toString.split() or label in field.fromString.split():
continue # Skip if label is not present in "TO" or present in "FROM"
if jiraDateToDaysDelta(update.created) <= LOOKBACK_TIME:
return True
else:
# If the ticket is new, or the label was added at ticket creation, this clause is hit
if label in ticket.fields.labels and jiraDateToDaysDelta(ticket.fields.created) <= LOOKBACK_TIME:
return True
return False

Suggest an answer

Log in or Sign up to answer