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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,466,414
Community Members
 
Community Events
176
Community Groups

How can I reference the custom field ID rather than its name in a Scriptrunner JQL query?

Hello Community

I am using a ScriptRunner JQL to find issue which have been created after the "Start Date" custom field.

issueFunction in dateCompare("", "created > Start Date")

This works well but now we run into a problem due to having two custom fields of the same type with the same name.

Does anyone how whether I can reference the customfield ID in the query rather than the name?

Also, I am fully aware that the correct way would be to clean up our Jira and avoid two custom fields of the same type and name but I need a shortcut now.

Many thanks

1 answer

1 accepted

1 vote
Answer accepted
carlosughini Community Leader Feb 22, 2022

Hi Nadine,

Using custom field's IDs rather than their names is a really good choice. Custom fields will have their ID next to the name of the field when suggesting fields in JQL like cf[12345]:

Screen Shot 2022-02-22 at 11.19.55 pm.png

So for example, if "Start Date" was cf[12345] you could have:

issueFunction in dateCompare("", "created > cf[12345]")

Please give it a try and let me know how it goes. I hope it helps.

Cheers,

Carlos 

Hello @carlosughini

Thanks a lot for the suggestion.

I am afraid it does not work for me though

 Message: Field name: cf[16300] not found or not a date or datetime

The ID is correct so it must either be the format or it's generally not possible to use cf IDs here.

carlosughini Community Leader Feb 28, 2022

Hey @Nadine Schuett ,

I'm afraid we are facing some type of bug or it is not able to search by id, unfortunately.

I've performed some tests on my side, even using "customfield_id" which is a Groovy code in the JQL, however, with no success.

I strongly recommend a support ticket here so Adaptavist can help you with this issue.

Please give it a try and let me know if you have any issues.

Regards,

Carlos

Hello @carlosughini 

I contacted Adaptavist support and they told me that the dateCompare JQL function does not support search using a custom field ID. 

However, I got the advice to use the even more powerful expression function and that works well:

issueFunction in expression("", "created > customfield_16300")

Thanks for your help and have a great day

Nadine

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events