Hello community,
I have a question regarding Behaviours from ScriptRunner addon.
Requirement: We need to have a script that has the behaviour of hiding and showing 2 fields that depends of a value from Support level field(see below).
Environment: Jira 7.13.13; Scriptrunner version – 6.5.0
Field 1 – "Support level" with the following values: 1st lvl support/2nd lvl support/3rd lvl support (single choice – custom field)
Field 2 – Story Points (nr field – custom field)
Field 3 – Sprint (Jira Sprint Field)
The issue that we have it that the script is working as intended but the part where it needs to set the values to “null” when 3rd lvl support is not selected is not working for Sprint field. For story points its working and the value is set to null. We have tried out also with “0” and “-1” values as int and also string but without any results. If we try to set the FormValue to int “1” then the Sprint Field is showing the first Sprint created, so the function is working but the Null value doesn’t.
Question: How can I setFormValue for Sprint field to null? Just to remove the selected sprint if someone choose not to go with 3rd lvl support option.
Behaviour script on “Support level” field:
import com.atlassian.jira.component.ComponentAccessor
if (getFieldScreen().name == "SD: Bug Edit Screen")
{
def story = getFieldById("customfield_10006")
def sprint = getFieldByName("Sprint")
def support = getFieldById(getFieldChanged())
def selectedOption = support.getValue() as String
def is3rdSelected = selectedOption == "3rd Level Support"
def defaultValue = null
if (selectedOption != "3rd Level Support")
{
story.setFormValue(defaultValue)
sprint.setFormValue(defaultValue)
}
story.setHidden(!is3rdSelected)
story.setRequired(is3rdSelected)
sprint.setHidden(!is3rdSelected)
sprint.setRequired(is3rdSelected)
}
Thank you in advance.
Best regards,
Andrei