Hi ,
I am trying to restrict fix versions field to accept a single value , can anyone provide suggestion on how can we achieve that from behaviours.
Hi @Likhita ,
this is an old suggestion https://jira.atlassian.com/browse/JRASERVER-15496 that has never been implemented.
My suggestion is to create a your own validator at workflow level or to put in place a behaviour provided by scriprunner plugin (https://community.atlassian.com/t5/Marketplace-Apps-Integrations/Restrict-Fixversion-to-one-value/qaq-p/214696)
Hope this helps,
Fabio
Hi @Fabio Racobaldo _Catworkx_
Thank your for your reply.
I tried with the code provided there its working expected when selecting with the existing versions when if incase two new versions its not throwing an error.
Could you please sugguest how can we manage with the newly created ones please.
This is the code which I Have modified and used
________________________________________________________________
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.ModifiedValueimport com.atlassian.jira.issue.util.DefaultIssueChangeHolderimport com.onresolve.jira.groovy.user.FieldBehavioursimport groovy.transform.BaseScript@BaseScript FieldBehaviours fieldBehaviours
def fixVersionsField = getFieldById("fixVersions")def selectedVersions = fixVersionsField.getValue() as List
// Ensure only one version is selectedif (selectedVersions.size() > 1) {fixVersionsField.setError("Please select a single value")}else if (selectedVersions.size() == 0 || selectedVersions.size() == 1){fixVersionsField.clearError()}
_________________________________________________________________________________
You must create your behaviour against the Fix Versions field so that the script is evaluated each time the field is modified.
And the script can be greatly simplified compared to the other post.
If you are just putting the script directly in the behaviour screen, you only need these 4 lines:
def fixVersionField = getFieldById('fixVersions')fixVersionField.clearError()if((fixVersionField.value as List).size() >1){ fixVersionField.setError('Please select a single value')}
If you use an IDE to write your scripts and want the autocompletion to work, you can add these 3 lines at the top:
import com.onresolve.jira.groovy.user.FieldBehavioursimport groovy.transform.BaseScript@BaseScript FieldBehaviours fieldBehaviours
While some may have had success with the above scripts, I wasn't able to successfully implement them. However, the following script works!
It looks like you're new here. Sign in or register to get started.