Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

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

Using scriptrunner's expression for fields with dashes in their name

Tiago Fernandes November 21, 2017

I'm using scriptrunner's issuefunction expression to compare two custom date fields in a jql. Example: issueFunction in expression("", "dateField1 < dateField2"). I'm having trouble when one of the custom fields have a dash in it, scriptrunner doesn't recognize the name of the field. When a field is called "date field 1", writing datefield1 on scriptrunner works. When a field is called "date - field 1", writing date-field1 on scriptrunner does not work.

 

Is there a particular way to escape dashes for custom field names in that situation?

3 answers

1 vote
Joshua Giffen May 11, 2021

issueFunction in expression("", "date - Field1 < date - Field2")

 

I was able to get a similar query working by using the customfield_##### reference instead of the customfield name.

issueFunction in expression("", "customfield_10600 < customfield_10601") 

1 vote
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 21, 2017

Hello, 

Try to write it like this

issueFunction in expression("", "\"date - field 1\" < dateField2")

Tiago Fernandes November 22, 2017 edited

That seems to result in an "java.lang.ClassCastException: null" error. I also tried it with system fields to make sure it wasn't an issue with the custom fields, the query

issueFunction in expression("", "\"updated\" < created")

results in that error, while if I remove the escaped quotes

issueFunction in expression("", "updated < created")

it works fine, returning zero results without any error.

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 22, 2017

Yep, I guess it treats is as a string not as a field name

Like Efrain Luna likes this
0 votes
Konrad Sass
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 31, 2018 edited

Hi, I'd like to second the question. I have exactly the same issue. I want to compare two custom fields with dates

While:

issueFunction in dateCompare("", "Date of deployment INT > Date of deployment UAT")

works fine, similar field but different environment crashes:

issueFunction in dateCompare("", "Date of deployment INT > Date of deployment PRE-PROD")

with an error:

Field name: Date of deployment PRE not found or not a date or datetime.

 

Is there any way to overcome that?

david_parry February 13, 2019

Could it be because you have "-" in your field name? Maybe quote escape so it doesn't attempt to parse the hyphen as a "minus" operator?

e.g.

issueFunction in dateCompare("", "Date of deployment INT > \"Date of deployment PRE-PROD\"")

Then the parser should treat Date of deployment PRE-PROD as a a single entity rather than "Date of deployment PRE" <minus> "PROD"

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, ace, atlassian community event, donation, girls who code, women in tech, malala fund, plan international, kudos, community badge, badge, atlassian badge, International Women’s month, International Women’s Day, women's month, women's day

10 for Change at Atlassian Community Events

Show up and give back by attending an Atlassian Community Event: we’ll donate $10 for every event attendee in March!

Join an Atlassian Community Event!
AUG Leaders

Upcoming Jira Events