Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

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 Confluence

An update on Confluence Cloud customer feedback – June 2022

Hi everyone, We’re always looking at how to improve Confluence and customer feedback plays an important role in making sure we're investing in the areas that will bring the most value to the most c...

265 views 2 5
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