Hi,
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)
}
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:
//Example
def otherField = getFieldByName("Field Name")
def otherFieldValue = otherField.value
//etc...
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
Thanks!
Aidan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.