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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


For loop - Behaviour


 Is it possible to use a for loop for behaviour. Basically, I have a select field (Number of Fields - options 1-10) and 10 text fields (Field Name 1 .. Field Name 2). Based on the selection in Number of Fields, I need to show the exact number of test field. Example, if I select 1 (on Number of Fields), Field Name 1 should show up. Same thing if I select 10, Field Name 1 to Field Name 10 should show up.

So I'm wondering if I can use for loop to accomplish this?

1 answer

Suggest an answer

Log in or Sign up to answer
1 vote
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Aug 15, 2023 • edited

With Groovy there are much better solutions for looping than standard for loops.


Try this:

import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

def selectFld = getFieldByName('Number of Fields')
def numberOfFieldsToShow = 0
def numberOfFieldsTotal = 10
if(selectFld.value) {
numberOfFieldsToShow = selectFld.value as Integer
def visible = number <= numberOfFieldsToShow
getFieldByName("Field Name $number").setHidden(!visible)

 (the first 3 lines are only needed if you work with an external IDE like intellij)

Thanks Peter! I'll try this one. 

AUG Leaders

Atlassian Community Events