ScriptedField returns number but can't query like it is a number

I have the following code in a scripted field:

def int days
try{
	def now = new Date()
	
		// get values of Created Date Information
		def Timestamp createdDate = issue.getCreated()		//TimeStamp
		def Timestamp resolutionDate = issue.resolutionDate	//TimeStamp
		//elapsed time
		def elapseTimeInMillis
		if (resolutionDate){
                	elapseTimeInMillis = resolutionDate.getTime() - createdDate.getTime()
		} else {
			elapseTimeInMillis = now.getTime() -createdDate.getTime() 
		}
		if(elapseTimeInMillis)	{
			def hours = TimeUnit.MILLISECONDS.toHours(elapseTimeInMillis)
			days = hours / 24
			def daysHours = hours - (days*24)
				
		}	
	
} catch (Exception e) {
	log.error "ERROR $e"
	0 as Double
}
days ? days as Double : 0 as Double

It is set up with a number template and a number searcher. When I display the column in a search, it displays numbers as expected. However, If I want to query the items that are greater than 2, I get no results. If I try querying using the field at all in the search, I get no results.

Here is my JQL from issue navigator: project = "CAT Group Policy Services" and "Age Since Received Number" >2

How can search on this numeric field?

1 answer

1 accepted

1 vote
Henning Tietgens Community Champion Jan 09, 2014

Did you reindex after you implemented the scripted field? Otherwise only changed issues get the correct value.

That was it - thanks, sometimes I forget the simplest things.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

76 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you