ScriptRunner's scripted field not showing up in issue navigator

Using Jira 5.2.2 and ScriptRunner 2.1.3

Problem: I have two fields, each containing multiple Jira versions. The standard field: 'Fix Version/s' and a custom field: 'Planned For'. The 'Fix Version/s' field can only contain versions or a subset of the 'Planned For' versions. I'm trying to created my first custom, scripted field: toPort (an unlimited text field) using ScriptRunner. This field will contain a string of the version names that is the difference/delta between the 'Planned For' and 'Fix Version/s' field.

import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import org.apache.commons.lang.StringUtils;

def pfNames = new ArrayList();

CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager();
def pfObj     = customFieldManager.getCustomFieldObjectByName('Planned For');
def pfList    = issue.getCustomFieldValue(pfObj);
def fixedList = issue.getFixVersions();
if (pfList != null) {
  pfNames =;
  log.warn("<<BW>>-01 " + StringUtils.join(pfNames, ", "));
  if (fixedList != null) {
    flNames =;
    log.warn("<<BW>>-02: " + StringUtils.join(flNames, ", "));
  log.warn("<<BW>>-03: " + StringUtils.join(pfNames, ", "));
return( StringUtils.join(pfNames, ", ") );

While editing this scripted field, I previewed each of the issues individually and the appropriate version names appeared in the preview pane. In the Issue Navigator, the columns were configured to show this new toPort field.

Then entered jql query#1:

The issues, I expected to be displayed, were displayed but the "toPort" column was not displayed. Then "toPort" was added to the jql query(known as query#2):

The issues, I expected to be displayed, were displayed but the "toPort" column was not displayed. Then "toPort" was added to the jql query(known as query#2):

The "toPort" column was now displayed in the Issue Navigator but only issues where "Fix Version/s" value were not null(empty), are displayed. Then I reversed the toPort portion of the query to check for empty. i.e. (known as query#3)

The remaining issues (query#1 - query#2) are not display along with null and non-null toPort values. Have I built in some dependency with the 'Fix Version/s' field or something that is preventing the displaying of the toPort field all the time in the Issue Navigator?

Any assistance would be greatly appreciated.

5 answers

1 accepted

0 votes
Accepted answer

Because my script is returning a string, even if it return a null string the "IS EMPTY" operator does not work on it. As well, the "~" contain operator cannot test for a null string as a result, I changed the return string from:

return( StringUtils.join(pfNames, ", ") );


def pfRet = StringUtils.join(pfNames, ", ");
if (pfRet) {
  return( pfRet );
} else {
  return( "none" );

So now I can test with the JQL syntax:

toPort !~ none

It may not be pretty but it works.

There's a difference between an empty string and null. If you return null, it will work properly. I'm not quite sure what you mean by a "null string".

You should change it to:

return pfNames.join(", ") ?: null

Thanks Jamie. I tried your solution but I still had the same issue with not being able to use the "is [not] empty" operator. But I will get rid of the StringUtils join...Thanks

Strange, I will test that. Don't forget you will need to reindex all issues affected if you change the script though.

The value displayed on the issue will update immediately you change the code. But, and this only applies if you use an indexer, the indexed value will not. It is only updated when the issue is indexed. A global reindex is the easy option. Another option is to use the method Henning suggested below, which will probably be quicker.

You should try to reindex the project with the new scripted fields. You could use a builtin script from Script Runner for that. After that, try again.

I reindexed the project from the Admin page menu but no difference. I've read numerous answers about the buildin script reindex feature but I don't see it in my 2.1.3 version of ScriptRunner. I noticed it is up to 2.1.9 so I'll upgrade first and then retry.

So I upgraded to ScriptRunner 2.1.9 with my existing 5.2.2 Jira and it got a little better but it is still not displaying properly.

As before the scripted field toPort has been added as a column in the Issue Navigator but if the JQL query does not include evaluating the toPort field then the toPort column is not displayed.

project = TBN and status = resolved

Here where it has changed, when I evaluate the toPort field

project = TBN and status = resolved and toPort is not empty

then all the issue that met the "project = TBN and status = resolved" are displayed along the the appropriate toPort value whether set or empty. e.g.

As you can see, it "seems" to be displaying empty and nonempty values of toPort. When I switch the jql to 'and toPort is EMPTY' then no issues are displayed. Hmmm. So I decided to try checking using contains syntax.

So it looks like the 'contains(~)' syntax can be used but when I try to use check for a null string.

Note: I can put other string values in that search and they work. So all my toPort field values are now not empty but I can't check if it is a null string.

So does it go back to Indexing? Is it something different?

I haven't had much luck putting in the appropriate code to index in the above scripted field code.

Any ideas would be muchly appreciated.

Just a note - if you don't use the correct tags, ie the one for this plugin, it's unlikely that all the right people are going to see your question.

I created a new scripted field, added the code then reindexed the project from the Admin page. Now the "is [not] empty" operator is working. I guess I need a better understanding of when to reindex. In this particular case, I don't need to reindex within the scripted code itself but if I change the code then I should do a project wide reindex from the admin page. Correct?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

804 views 3 9
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you