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.
Hi Keval,
Could you please specify what is the type of your custom field, i.e. number, date or string values?
thanks
Adel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
oh! thats strange. thanks for this info
is there any other way I can compare this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
where these functions ae re writen in jira
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.