Hi Guys,
how could one filter the selectable values of the "Fix Version/s" field by a filter which is different for each project? (Filtercriteria could e.g. be a value of some custom field, or a category)
Also the displayed name of the versions should be adapted (e.g. remove prefixes)
Example:
Project A has the versions
Pref1_1.1_x
Pref1_1.2_y
Pref2_3.2_z
Pref2_4.1
now based on a filter only versions with prefix "Pref1" should be shown, the displayed names of the versions should miss the prefix - so this versions would be the result:
1.1_x
1.2_y
Kind regards, Christoph
Community moderators have prevented the ability to post new answers.
Hello,
There is no option like this. What are you trying to do? Are you developing your own plugin for Jira?
I wanted to do this with a behaviour ... some projects has tons of versions which should be filtered to make it easier to choose.
Some colleague meant to maybe solve this with a custom field (multiselect) which gets filled when loading the edit screen... but this seamed to be a bad hack.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do you mean ScriptRunner behaviour?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think it is possible to limit Fix Versions with ScriptRunner behaviour, but I was not able to find any code.
You can try to use the solution of your colleague or you can try the Power Scripts add-on. There is a similair feature to behaviours, called Live Fields.
You code would look like this:
lfRestrictSelectOptions("fixVersions", {"Version1", "Version2"});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Temporary I solved it with a custom field (multiselect) which get filled with all possible values in one script.
Another script filters the shown Options.
BUT: We really should consider Power Scripts because the actual workaround has about 100 lines of code
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't know if there is a better way of filtering the versions in the fixVersions field with ScriptRunner.
(We additionally have the problem that the "Configuration Management Toolkit" plugin also filters the versions - but with another filter)
So finally I found a "dark hack".
If one sets the description of a field it can be done with html with an <script></script> tag in it... the script gets executed.
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
class FixVersionsFilter extends FieldBehaviours {
def run() {
def piVersionsRegex = "/^sws.*/i"
FormField fixVersionField = getFieldById("fixVersions")
fixVersionField.setDescription(
"<html>" +
" <body>" +
" <div></div>" +
" <script type=\"text/javascript\">" +
" var onChange = function(element, callback) {" +
" var HTML = element.innerHTML;" +
" var debounce = false;" +
" window.setInterval(function() {" +
" var newHTML = element.innerHTML;" +
" if (HTML !== newHTML) {" +
" debounce = true;" +
" HTML = newHTML;" +
" } else if (debounce && HTML === newHTML) {" +
" debounce = false;" +
" callback();" +
" }" +
" }, 500);" +
" };" +
" var filterFixVersions = function() {" +
" var releasedVersion = \$(\"#fixVersions>optgroup[label='Released Versions']>option\");" +
" for(var i = 0; i < releasedVersion.length; ++i){" +
" if (${piVersionsRegex}.test(releasedVersion[i].text)){" +
" releasedVersion[i].remove();" +
" }" +
" }" +
" var optionsUnreleased = \$(\"#fixVersions>optgroup[label='Unreleased Versions']>option\");" +
" for(var i = 0; i < optionsUnreleased.length; ++i){" +
" if (${piVersionsRegex}.test(optionsUnreleased[i].text)){" +
" optionsUnreleased[i].remove();" +
" }" +
" }" +
" };" +
" \$(document).ready(function(){" +
" filterFixVersions();" +
" var fixVersionsElement = \$(\"#fixVersions\")[0];" +
" onChange(fixVersionsElement, function() {" +
" filterFixVersions();" +
" });" +
" });" +
" </script>" +
" </body>" +
"</html>"
)
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.