Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,555,948
Community Members
 
Community Events
184
Community Groups

How use scripted number field in jira filter?

Edited

I have scripted the number field "Issue Age", which calculates the issue created date and the current date and displays the number of days. I would like to display the issue age in Jira Dashboard, I created three filters, one is to display issue age that has a number 15 or less, the second is 16 to 30 and the third one is 31 and more. 15 or less, and 30 or more seem to be working fine. But the middle one is not working. It is displaying issues for those more than 30 days old, like 35, 39, etc. It is supposed to not display more than 30. Any idea why it's not working and how can I fix it? Here are all three filters:

Less than 15: project = HR AND issuetype in (Bug, Story, Task) AND resolution = Unresolved AND "Issue Age" < "15" 


 16 to 30: project = HR AND issuetype in (Bug, Story, Task) AND resolution = Unresolved AND "Issue Age" >= "16" AND "Issue Age" <= "30"

31  and greater: project = HR AND issuetype in (Bug, Story, Task) AND resolution = Unresolved AND "Issue Age" >= "31"

First filter <15 only time works if I do not include equal (=) if include <= then it includes issues that have more than 15 days in age field. I'm not sure if the custom number field behaves differently than text fields?

Thank you for your help.

1 answer

1 accepted

0 votes
Answer accepted
Radek Dostál
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.
Apr 26, 2022 • edited

Assuming you are in fact returning a number (not a string where searcher could be a suspect), then those less than or equal etc. should be fine - not really doubting those.

 

I think what you might however be hitting is old caches - scripted fields do not have reliable indexes to be used in filters.

This is better explained here: https://scriptrunner.adaptavist.com/6.20.0/jira/scripted-fields.html#_more_advanced_notes_on_caching

 

Quote of interest 1:

It’s also possible to search on these values if you set up one of the four shipped searchers. If you do, the value is calculated and stored in the index at the time that the issue is indexed, eg when it is modified or transitioned, or when you do a full reindex.

Quote of interest 2:

The reason why is because the value in the Lucene index is only updated when the issue is updated.

 

As far as JQL Searches go, in your case, you would get more accurate results by using native JQL functions such as created > -15d, or created > endOfDay(-15d), or something to that extent (https://support.atlassian.com/jira-software-cloud/docs/advanced-search-reference-jql-functions/#Advancedsearchingfunctionsreference-endOfDayendOfDay--). Key point being that using the 'created' field is trusty index value, whereas scripted fields can't be trusted.

Thank you @Radek Dostál for your response. it was a little bit confusing since the issue age was getting calculated twice once the issue got created, and the second time when the issue got resolved. During issue creation, it was using the current date and a custom date field (issue identified date) which is earlier than the creation date most of the time. The second time it was calculating the creation date and resolved date.

However, I made it work with the custom date field (Issue Identified date). Thanks

 

project = HR AND resolution = Unresolved AND "Issue Identified Date" >= -45d  AND "Reported Date" <= -31d

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events