How to set value for radio button or check boxes in Behaviours plugin


I am trying to access a radio button and/or a check box to then set value for other custom fields on our form using the Behaviours plugin, but can seem to get the right syntax ... this is the one scenario with a radio button

  • Solution is a single select field
  • Security Required is the radio button, values are: Yes, No, Do Not Know, defaults to None.
  • the snipet of Behaviours code:

FormField Solution = getFieldByName("Solution")
FormField Security = getFieldByName("Security Required?")
String SolutionVal = (String) Solution.getValue()
if (SolutionVal == "Solution 1" || SolutionVal == "Solution 2")

{ Security.setFormValue("Yes") }


{ Security.setFormValue("Do Not Know") }

1) what is the proper setFormValue syntax in this case
2) what would be the syntax of the equivalent getFormValue (say the radio was set to "Yes") -looking to be able to compare like (if radioVal == "Yes") { do something }
3) what is the syntax if instead of a radio button Security were a checkbox, so set the value for both "No" and "Do Not Know" -ignoring fact these labels are mutually exclusive
4) finally what is the equivalent getFormValue for retrieves all the values of a checkbox.

1 answer

2 votes

Hi William,

You should attach the following script to your "APS Solution" field with behaviours:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.Option
import com.onresolve.jira.groovy.user.FormField

def solutionField = getFieldById(getFieldChanged()) // this is APS Solution 
def securityField = getFieldByName("MSM Security Required?") // radio button

def solutionValue = solutionField?.value
if (solutionValue == "Retail" || solutionValue == "Loyalty") {
    securityField.setFormValue(optionFor(securityField, "Yes").optionId)
} else {
    securityField.setFormValue(optionFor(securityField, "Do Not Know").optionId)

private Option optionFor(FormField securityField, String value) {
    def optionsManager = ComponentAccessor.getOptionsManager()
    def customFieldManager = ComponentAccessor.getCustomFieldManager()
    def customField = customFieldManager.getCustomFieldObject(securityField.getFieldId())
    def config = customField.getRelevantConfig(getIssueContext())
    def options = optionsManager.getOptions(config)
    def optionToSelect = options.find { it.value == value }

There is also some examples in the documentation that can help you piece this together. First setting the values: 

Also setting value based on another field changing:

Hope this helps,

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


245 views 0 6
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