The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Using Cloud Behaviours to display/hide field based on another supported field?

pamela_ng
February 28, 2023

I am using Scriptrunner Cloud Behaviours to display/hide field based on another field's value.

Field changed and field to be hidden/displayed are of single select type. This field type is supported by behaviours (https://docs.adaptavist.com/sr4jc/latest/features/behaviours).

Based on the documentation, I would want to display the field only if the value of another custom field is true (https://docs.adaptavist.com/sr4jc/latest/features/behaviours/behaviours-api)

While I am able to hide the affected field on load using .setVisible(true), I am unable to display the field on change using .setVisible(false).

Below is my code snippet.

const fieldChangedValue = getFieldById("customfield_10255").getValue().name;
const siteCF = getFieldById("customfield_10254");

if (fieldChangedValue == "Site"){
    siteCF.setVisible(true);
}

Any advice? 

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
Answer accepted
Chasovskikh Kirill
Contributor
April 6, 2023

hi!

this method makes your customfiled hidden

getFieldById("customfield_10254").setVisible(false);

if you want to hide your field in default view and show it for option "Site", you need to use this code

getFieldById("customfield_10254").setVisible(false);

const fieldChangedValue = getFieldById("customfield_10255").getValue().name;
const siteCF = getFieldById("customfield_10254");

if (fieldChangedValue == "Site"){
siteCF.setVisible(true);
}
Cesar Duran
March 22, 2024

This is just what I was looking for, thanks.

Like • Chasovskikh Kirill likes this
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events