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.
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.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def fixVersionsField = getFieldById("fixVersions")
def selectedVersions = fixVersionsField.getValue() as List
// Ensure only one version is selected
if (selectedVersions.size() > 1) {
fixVersionsField.setError("Please select a single value")
}
else if (selectedVersions.size() == 0 || selectedVersions.size() == 1)
{
fixVersionsField.clearError()
}
_________________________________________________________________________________
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.