I have a Single Select List Custom Field called "Test Request Type" Options include Level, Character, and Weapon.
When Creating a "Test Request" issue type (on the Create screen), I would like to dynamically change the Description field based on the user's form selection of the Test Request Type field.
To accomplish this, I have tried using Scriptrunner Behaviors.
The code block below is a serverside script attached to the Test Request Type field, but I can't get the Description field to update dynamically based on the user's choice.
Any help would be appreciated!
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.customfields.option.Options
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import groovy.transform.BaseScript
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
FormField testRequestType = getFieldByName("Test Request Type")
def stringValue = testRequestType.getValue() as String
if (stringValue == "Level")
{
def desc = getFieldById("description")
def defaultValue = """h2. How to reproduce
* step 1
* step 2
h2. Expected Result
The widget should appear
h2. Actual Result
The widget doesn't appear""".replaceAll(/ /, '')
desc.setFormValue(defaultValue)
}
Hi Jordan,
What does the behaviour configuration screen look like? and what version of JIRA and SR are you using?
I have just recreated the environment you described and use the exact same code and got the below result. This makes me believe it is something in the configuration of the behaviour.
What is the error? Did you add the Test request type to the behaviour and add the script to the field? Kindly log info into logs and see the logs
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.customfields.option.Options
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import groovy.transform.BaseScript
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
FormField testRequestType = getFieldByName("Test Request Type")
def stringValue = testRequestType.getValue() as String
log.error("stringValue:" + stringValue)
if (stringValue == "Level")
{
def desc = getFieldById("description")
def defaultValue = """h2. How to reproduce
* step 1
* step 2
h2. Expected Result
The widget should appear
h2. Actual Result
The widget doesn't appear""".replaceAll(/ /, '')
desc.setFormValue(defaultValue)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.