Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Hi Keval, 

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

 

thanks 

Adel

both the custom fields are strings

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, 

Thanos

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.

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

Regards

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Why everyone using Jira must be GDPR-compliant

Did you know that penalties up to 4 % of the yearly company turnover are possible in case of GDPR violations? GDPR regulations are currently mainly relevant for companies in the EU, but countries lik...

81 views 1 2
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