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

Customfields with spaces in a Scriptrunner JQL expression

I am trying to use the "expression" function in scriptrunner for jql. But my customfields have a space in their name and hence I am getting an error.

This is the jql I am trying:

issueFunction in expression("", "\"ABC D\" = \"EFG H\"")

Can you please help me with the correct way to write such a query? I was also looking at ways where I can specify the customfield ids rather the names but couldn't find it.

1 answer

1 vote
Mohamed Adel Community Leader Aug 20, 2018

Hi Keval, 

Could you please specify what is the type of your custom field, i.e. number, date or string values?




both the custom fields are strings

Mohamed Adel Community Leader Aug 20, 2018

The problem is that IssueFunction doesn't support custom fields with spaces as mentioned here, also IssueFunction can help as long as your custom fields are date, datetime or numeric fields only. 

oh! thats strange. thanks for this info
is there any other way I can compare this?

Well Keval you can use the issueFieldMatch to query any field by regular expression. 

And as you mentioned if your field has spaces the you can use the id of the field, so for example, in order to find out all the fields that the custom field with id customfield_10300 contains the character a you will need something like 

issueFunction in issueFieldMatch("", "customfield_10300", "a")

PS. A quick way to find the id of your custom field will be to go to your Script Console and run the following script 

import com.atlassian.jira.component.ComponentAccessor

ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Text Field").id

Hope that helps, 


Like Joshua Giffen likes this

Thanks @Thanos Batagiannis _Adaptavist_

I checked out the issueFieldMatch function and its great to match against a constant value. But, in my case I would like to compare two custom fields and I believe that's not possible. Let me know if I am wrong.

Mohamed Adel Community Leader Aug 21, 2018

Hi keval,

i would recommend to have another scriptfield to compare the two values and return True/False 


if this can solve your problem we can work on it for you 

Yes. That's indeed a good idea.

However I believe this should be very native feature to JQL as having the above solution is good in a case or two. But when this is to be done across many fields, it wouldn't be elegant.

Hi Keval, 

Kindly, create a scripted filed custom field (Free Text Srearcer) and use the following script: 


After that you can use JQL to search for True/False values. 


import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Logger

def CustomFieldManager = ComponentAccessor.getCustomFieldManager()

def log = Logger.getLogger("")

def customfield1 = CustomFieldManager.getCustomFieldObjectByName("ABC D")
def customfield2 = CustomFieldManager.getCustomFieldObjectByName("EFG H")

if (issue.getCustomFieldValue(customfield1) == issue.getCustomFieldValue(customfield2)) {
return "True"
else {
return "False"


I hope this will help you


Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

Do you use Jira Cloud with Microsoft Teams?

Hi, Jira users! Do you use Jira alongside Microsoft Teams? We want to hear how you’ve used the power of Jira Cloud and Microsoft Teams (via the Jira Cloud for Microsoft Teams app) to achieve a team...

481 views 3 7
Read article

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