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,556,451
Community Members
 
Community Events
184
Community Groups

ScriptRunner Scripted Field Not Available for JQL Search

I've added two ScriptRunner Scripted Fields to my Jira instance... 

  1. Sprint Start Date
  2. Sprint End Date

These fields will look at the defined start/end dates for the Sprint and stuff those into the two custom fields appropriately. Everything works fine... I can pull these fields into columns on the "Search for issues" however when I try and use these two new fields as part of a JQL Search, they're not available.searchForIssuesn_noJQLOption.PNG

This is just one of my Scripts to return the Sprint Start Date... 

// Required Imports
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import java.text.SimpleDateFormat;
import java.util.Date.*;
import com.atlassian.jira.issue.customfields.searchers.TextSearcher

// Get the current issue key
Issue issue = issue

// Get a pointer to the CustomFieldManager
def customFieldManager = ComponentAccessor.getCustomFieldManager()

// Get a pointer to the sprint CF
def sprintCf = customFieldManager.getCustomFieldObjectByName("Sprint")

// Stop the values on screen showing old cached values
enableCache = {-> false}

// Define a new Java Simple Date Format
SimpleDateFormat sdfDate = new SimpleDateFormat("dd/MMM/YYYY");

// Get the Start Date for the Sprint
Date sprintStartDate = issue.getCustomFieldValue(sprintCf)?.startDate?.first()?.toDate()

// Return the output Date
return sprintStartDate

I re-indexed Jira after the field was implemented. 

What am I doing wrong? Why can't I use JQL to Search on these fields? 

Thanks in advance!

1 answer

1 accepted

2 votes
Answer accepted
mogavenasan
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.
Feb 17, 2021

Hi @Shawna Morris,

If you want to search on the calculated value then you will need to configure an indexer. Take a look at this doc
image.png

Do you have this configured?

I guess the second time is a charm in this case. I was fiddling with the Searcher and had previously tried the "Date Time Range picker" and it didn't work. Now it is. Thank you for having me double-check! 

Like mogavenasan likes this
mogavenasan
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.
Feb 18, 2021

Woohoo!

@mogavenasan I don't understand how you get to that screen where a searcher can be selected - please can you explain? 

I don't see that option when creating a new Scripted Field, nor when editing one.

Hello, this is Olly from ScriptRunner Support!

Searchers for each Scripted Field can be found when looking at the Administrator ->  ScriptRunner's Field page as per the below:

Screenshot 2022-06-29 at 13.51.14.png

Furthermore, I've noticed @mogavenasan linked our old Documentation!
We've recently moved everything to a new page here! 

Specifically, the page in question for this question is here!

Kind Regards,

Olly

Like oguzhankr likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events