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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

0 votes
Answer accepted

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

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Trello

Taco Tuesday: Your favorite Trello blog takeaway

Hello friends! From the community that brought you Welcome Wednesday, Throwback Thursday and Friday Fun, welcome to Taco Tuesday, a weekly discussion about all things Trello. The best part? One Tac...

67 views 4 3
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you