Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira\Scriptrunner groovy code to write to a JQL searchable field

W. Klein
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 12, 2021

I have a working Jira Scriptrunner script which reads all of the linked issues and then based on linked type, writes that linked issue id to a custom field, example what the script does:

  • Current issue is abc-1 which has the scripted field on its screen and has a linked issue xyz-1 via a 'realizes' link type.
  • Writes 'xyz-1' to a custom field named 'Issues linked by realizes'. This custom field is a single line text type.

What I cannot find is a way is to search this custom field by value = 'xyz=1'.

Questions:

  1. Is there a way to search a Jira text custom field for a value?
  2. Should I write, in the above example 'xyz-1', to different type of custom field which I can search?

1 answer

0 votes
Nic Brough -Adaptavist-
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.
December 13, 2021

You can't do this, and I think you've already worked out why!

Not because the idea or the code are wrong, but because text fields cannot be searched like that.  They take only fuzzy searches, and depending on your choice of project keys,  the JQL

"Issues linked by realises" ~ XYZ-1 

may not reliably do what you want!

The easiest thing that I think would fix this is to (re)create "Issues linked by realises" as a field of type "label".  Labels are directly searchable as though they are select lists, but do not need to have an option added to them before you can select it, so your code for populating the labels field would not have to do that as well as setting a value.

Suggest an answer

Log in or Sign up to answer