Filtering issues in Behaviours

Hi all,

I have a workflow with screens on Start progress and Resolve and two issue types (Incident and Service request) linked with this workflow. 
On these screens there is a field "Incident affected" which is not needed for Service request issues. 
Now I want to hide this field with "Behaviours" for all issues with Service request issue type and for Incidents, if priority is lower than Medium. current variants in conditions are inappropriate for this case.

maybe there is a way to make an advanced searching issues with jql in Behaviours?

1 answer

1 accepted

2 votes
Answer accepted

You can achieve this by using the underlyingIssue binding in an initialiser script for the behaviour like below:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.PriorityManager
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

// this is issue create and we have no underlying issue yet
if (! underlyingIssue) {

def issueTypeName = underlyingIssue.getIssueTypeObject().getName()
def priortityManager = ComponentAccessor.getComponent(PriorityManager)

// get medium priority
def mediumPriority = priortityManager.getPriorities().find { priority -> == "Medium"

// the higher the priority sequence number the lower the priority
if (issueTypeName == "Service request" || (issueTypeName == "Incident" && underlyingIssue.priorityObject.sequence > mediumPriority)) {
    def incidentField = getFieldByName("Incident affected")


JQL is not really well suited to this as you would need to search through all the issues when you already have the issue available here, its not very feasible as it needs to run every time someone views a page.

Hope this helps,

Thanks, Adam! 

it must be added to "Add serverside script", isn't it? 

can we set some value for "Incident affected" (it is a single choise select list) here in this script or it have to be done from the workflow transition? 

Yes thats correct, it should be added to the initialiser like in this example:

Theres an example for setting a default value for the select list here:

But if you don't want the user to edit this default selected value you also need to add:





added this lines (needed to set a value by default when it's hidden), it works correctly.

thanks a lot! 

def IncidentAffected = getFieldByName("Incident Affected")
int defaultVal = 10404 //single user

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 13, 2019 in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


203 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you