Hi,
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
FormField Solution = getFieldByName("Solution")
FormField Security = getFieldByName("Security Required?")
String SolutionVal = (String) Solution.getValue()
if (SolutionVal == "Solution 1" || SolutionVal == "Solution 2")
{ Security.setFormValue("Yes") }
else
{ Security.setFormValue("Do Not Know") }
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 } optionToSelect }
There is also some examples in the documentation that can help you piece this together. First setting the values: https://scriptrunner.adaptavist.com/latest/jira/recipes/behaviours/setting-default-fields.html#_setting_defaults_for_selects_etc
Also setting value based on another field changing: https://scriptrunner.adaptavist.com/latest/jira/recipes/behaviours/select-list-other.html
Hope this helps,
Adam
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.