Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Field validation for a single issue type

Frank Winkler August 23, 2018

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

 

1 answer

1 accepted

1 vote
Answer accepted
Nir Haimov
Community Champion
August 23, 2018

Hi @Frank Winkler

Yes, you can do it from Behaviours.

Admin cog -> Add-ons -> Behaviours

  1. Add new behaviour
  2. Click "add mapping" to map it to the projects you want
  3. Click "Fields" to choose the field you want.
  4. Once you choose the field you have 3 behaviours for it:

Choose "Required"

That's it

Frank Winkler August 23, 2018

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

Nir Haimov
Community Champion
August 23, 2018

You are right, it will be mandatory for all,

Let me know tomorrow if your script work or not. :)

Frank Winkler August 26, 2018 edited

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

Nir Haimov
Community Champion
August 27, 2018

Great!

glad to hear it worked out :)

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, team '25 europe, atlassian event, barcelona 2025, jira, confluence, atlassian intelligence, rovo, ai-powered collaboration, developer tools, agile teams, digital transformation, teamwork solutions, atlassian conference, product announcements

🌆 Team '25 Europe registration is now open!

Join the largest European gathering of the Atlassian Community and reimagine what’s possible when great teams and transformative technology come together. Plus, grab your Super Fan ticket now and save over €1,000 on your pass before prices rise on 3 June.

Register now
AUG Leaders

Atlassian Community Events