The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

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

Nancy Blackwell
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 Champions.
January 9, 2014

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
Answer accepted
Henning Tietgens
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 Champions.
January 9, 2014

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

Nancy Blackwell
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 Champions.
January 9, 2014

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

TAGS
AUG Leaders

Atlassian Community Events