Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Set comment required based on another custom field value


I want the comment added during the transition to be required or not depending on the option selected. I wrote the validator, unfortunately it does not work and does not require the user to add a comment.


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

def commentField = getFieldById("comment")
def cfManager = ComponentAccessor.getCustomFieldManager();
def cf = cfManager.getCustomFieldObjectByName("Options");

switch(issue.getCustomFieldValue(cf) as String){
case "No": commentField.setRequired(true)


1 answer

Hey there Tomasz!

First, are you using a transition screen coupled with the Behaviour? Behaviours aren't active on just the View Issue Screen, so to get something like this working you'll need to implement some sort of transition screen that has these fields on it.

Second, if you are already using a transition screen, is the custom field that you are trying to get the value of also available on the same screen or is it just available on the issue? If it's available on the same screen as the Comments field, then you can use the Behaviour methods to get the field and the field value:

def otherField = getFieldByName("Field Name")
def otherFieldValue = otherField.value

Additionally, what type of custom field are you trying to get a value from? For example, is it a Text field, a Single Select field, a Multi-select field, etc...

This info will help me try this out myself and see if I can get something figured out for you :D



Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

⏰ Day in the life of a Jira Admin!

Hello Community! We thoroughly enjoyed this just-for-fun conversation in the Jira Admin Group about what it's like to be a Jira Admin. For #JiraJuly, our talented designers created these graphics t...

520 views 2 18
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you