JIRA Behaviour change one field based on change to another

C_ Derek Fields
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 5, 2018

I have worked through how to use Behaviours to update a select list options at form initialization. I think that there should be a way to update the select list options based on a change to another field on the screen. I think that this should be part of a condition, but I can't figure out how this gets configured in the Behaviour module.

 

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 5, 2018

Hello,

Let s say you have two fields: "Parent field", "Child field". You have to create a behaviour and add "Parent Field" to the behaviour. Then you should add a script to the "Parent Field" (it is important to add the script to the Parent Field not to the behaviour as you did before).

You script would look like this

def parentField = getFieldByName("Parent Field")
def childField = getFieldByName("Child Field")
if (parentField.getValue().equals("1"))
{ chilField.setFormValue("my value")}

I did not check the script but that is the idea how it should work.  If you have any further questions, do not hesitate to ask.

C_ Derek Fields
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 5, 2018

Great - you answered my question. It is not clear from the documentation (or I just did read it closely enough) that the behaviour of the field is triggered on the change to the field. Now that I see it, it becomes pretty obvious.

Elena Oleksenko June 22, 2018

Hello, could you please clarify what it mean "add script to the field not to the behaviour"? You mean to field description? 

徐佐君 December 16, 2022

Hi Alexey, your solution works on the editing page, the child field updated while changing the parent.

But I found it do not work on the creating dialog.  It is the popup window when creating. After the parent field was changed, the child field is expected to be updated.  The script seems do not work on this window. Do you have any idea? Thank you any way.

TAGS
AUG Leaders

Atlassian Community Events