JQL:
For example I have a multi-choice field called Team nad I want via JQL to see all the Issue that are marked to impact more than one team. Writing an explicit querry (Teams = Team1 and Teams = Team2) is not an option as if I have 4 teams the possible combinations are 11.
Script:
How can I get the number of options selected for a multi-select custom field via Script.
You can create a scripted field
return ((getCustomFieldValue(10090)?.size())?:0) as Double
to get the number of selected values for customfield 10090. Use Number template and searcher. After creating the field you have to reindex all issues.
Than you can use this field to find all issues with scripted_field > 2.
Got the same request, have to count the choosen options of a multi-select field. Created a scripted field and added your code, but seems to be not working?!
Any ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The code is a couple of years old, but should still work. I'd break it down using a test issue - in the script-runner scripted field definition, there's a "preview" option, so you should use that to build up the query and see where it goes wrong.
i.e. try these (with the output type set to string)
return getCustomFieldValue (10090)
return getCustomFieldValue (10090).size()
Then add back the ? stuff - that's there to prevent errors when the field is empty or not valid for the issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
JQL is not SQL. JQL finds issues that match criteria, it has nothing to do with the output.
So, you can use it to say
and so-on. Note that those human-language questions say absolutely nothing about the issue data that comes back, the counters of results or anything else. The answers from JQL are just issues that match the question.
If you have 11 combinations, you're going to need 11 queries to pull them out, and then you can push them through assorted gadgets or reports that might do the sums for you.
I suspect the best you can do is a derived field of some sort (with a bit of code) - something that shows the number of selected options, and maybe concatenates them together so you can interrogate it as unique strings.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was not interested in the output but just a list of issues similar to any JQL where selected options are > 2
What do you mean by derived field? A scripted field (add-on scripts) or just a numeric hidden field that shows the number of options selected. I prefer the latter but I can't keep the cound up-to date as I can put easily logic to udpate that field on Edit.
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.