Forums

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

ScriptRunner Scripted Field Not Available for JQL Search

Shawna Morris
Contributor
February 17, 2021

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

Suggest an answer

Log in or Sign up to answer
0 votes
Darin Hafer
Contributor
August 12, 2020

Hi @Siavosh Kasravi, in my experience with this, even when Attachments are indeed sent, you won't see it reflected in the test results that you show in your screenshot. I'm on Jira 7.9.2 and ScriptRunner 6.3.0.

 

Were you able to determine why your attachments did not send? For me, I have to try it for real and not rely on the test results in this case.

TAGS
AUG Leaders

Atlassian Community Events