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,560,577
Community Members
 
Community Events
185
Community Groups

Sorting and searching of scripted number field does not work

Hi there,

 

I have a scripted number field which gives me the number of requirement tests for a story. The script only executes a JQL (type = Testfall AND issue in requirementTests(" + issue.key + ")) and returns the search count as double value. This works fine.

When I try to use this field in issue search I get the results displayed but can not use it in search or while sorting issue by this field value.

Here the script:

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.issue.search.DefaultSearchService
import com.atlassian.query.Query
import com.atlassian.jira.user.ApplicationUser

def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchService = ComponentAccessor.getComponent(DefaultSearchService)
def ApplicationUser user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()

if (user != null && user.isActive()) {
// edit this query to suit
Query query = jqlQueryParser.parseQuery("type = Testfall AND issue in requirementTests(" + issue.key + ")")
if (searchService.searchCount(user, query).doubleValue()) {
return searchService.searchCount(user, query).doubleValue()
} else {
return 0
}
}

 

Is there anyone who can help me?

 

Best Regards

Lubi

 

2 answers

I have updated Scriptrunner to Version 6.13.1 but sorting and searching does still not work. What can I do else?

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.
Nov 12, 2020

I'd raise this directly with the SR support team.

The numeric scripted field I've got that returns like yours does works fine when the number-range searcher is selected for it.  Although I have a nagging doubt it returns a long rather than a double, I can't imagine that would be the answer.

0 votes
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.
Sep 17, 2020

In the script settings, is the output template set to be a number field?

When you go to Custom fields -> Your scripted field -> Edit, what do you have set for a "searcher" for it?

Hi Nic,

i already tried number search for exact number and number range.

Regards

Lubi

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.
Oct 03, 2020

Did you re-index after changing the searcher?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events