Hi,
we have a custom field "Affects version(s)". This should be made mandatory for a group of projects - but only for one issue type (Bug). In workflow transitions it's easy to do this validation using a Custom Script Validator from ScriptRunner. But how can I do this when the issue is edited - Edit is no workflow transition?
I suppose this could be done using Behaviours but couldn't find the point where to put my validation script.
Thx in advance!
Frank
Yes, you can do it from Behaviours.
Admin cog -> Add-ons -> Behaviours
Choose "Required"
That's it
Hi @Nir Haimov,
thx for your reply. Unfortunately this would make the selected field required for all issue types. But it must be mandatory only for Bugs.
I think the solution could be a script like this (as Initialiser and at field "Issue type")
def issueTypeId = getFieldById("issuetype").getValue() as String
def affectsVersionField = getFieldById("customfield_11023")
if ( affectsVersionField ) {
if (issueTypeId == "1") { //Bug
affectsVersionField.setRequired(true)
} else {
affectsVersionField.setRequired(false)
}
}
But unfortunately at the moment it doesn't work. I'll have a look at it tomorrow.
Regards!
Frank
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are right, it will be mandatory for all,
Let me know tomorrow if your script work or not. :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nir,
after some research (first I used a wrong field ID) this script works perfectly.
def issueTypeId = getFieldById("issuetype").getValue() as String
def affectsVersionField = getFieldById('versions')
if ( affectsVersionField ) {
affectsVersionField.setRequired(issueTypeId == "1") //Bug or not
}
Best regards!
Frank
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.
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.