Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Using Behaviours to display or hide a field based on option selected from another field

Thảo Nguyễn
Contributor
February 7, 2023

Hi everyone,

I'm trying to write a script on Behaviours display or hide a field based on option selected from another field.

On a workflow transition screen, I have 3 fields:

Routine (customfield_18602)
Fin Approve (customfield_18603)
CEO Approve (customfield_18604)

If the user selects "YES" in Routine (customfield_18602) , then Fin Approve (customfield_18603) appear and CEO Approve (customfield_18604) should be hidden.

If the user selects any other value, then CEO Approve (customfield_18604) appear and Fin Approve (customfield_18603) should be hidden.

Please help me with this problem!

Thanks for your view and hope to your comment.

1 answer

1 accepted

0 votes
Answer accepted
Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 7, 2023

Hi @Thảo Nguyễn ,

please try the floowing code in your behaviour associate to Routine field :

 

def routineField = getFieldByName("Routine");
def finApproveField = getFieldByName("Fin Approve");
def ceoApproveField = getFieldByName("CEO Approve");
String routine = routineField.getValue()
if("YES".equalsIgnoreCase(routine)){
        finApproveField.setHidden(false);
        ceoApproveField.setHidden(true);
} else {
        finApproveField.setHidden(true);
        ceoApproveField.setHidden(false);
}
Hope this helps,
Fabio
Thảo Nguyễn
Contributor
February 7, 2023

Hi @Fabio Racobaldo _Herzum_ 

Thanks for your scripts. But I mean that when the user selects "YES" in Routine then CEO Approve(customfield_18604) should be hidden immediately on the screen. 

I try on Routine field with Select List type and Radio button type but it doesn't work.

Please help me if there is any solutions about it.

Thank you so much,

Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 7, 2023

Is ROutine a select list field or a radio button?

Thảo Nguyễn
Contributor
February 7, 2023

I try 1 Routine field is Select list and 1 Routine field is radio buttton.

But they don't work.

Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 7, 2023

My code is for a select list filed. Please add this code to field "Routine" so it works each time that user cahnge its value.

Like Thảo Nguyễn likes this
Thảo Nguyễn
Contributor
February 7, 2023

Thank you so much, 

It's my mistake when add script in Initialiser. I added it on field "Routine" and it works well.

Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 8, 2023

you're welcome @Thảo Nguyễn 

Suggest an answer

Log in or Sign up to answer