How to Dynamically Add Sections in a Jira Form Based on User Input?
Asked by Manuel Alvarez:

Hi Atlassian Community,

I'm currently working on a project in Jira where I need to create a dynamic form that can add sections based on a user-selected value. The challenge I'm facing is to dynamically generate identical sections for each entry a user specifies in a previous field.

To illustrate with an example, let's say the form  
is for entering passenger information for a flight. If a user indicates there are 3 passengers (using a numeric field), I need the form to automatically generate 3 identical sections, each dedicated to capturing the details for one passenger.

Could anyone guide me on how to achieve this in a Jira form? Are there any specific plugins, scripts, or built-in functionalities that I can leverage to create such dynamic forms?

Thank you in advance for your help!


Answers:
author: Mikael Sandberg
body: Hi [@Manuel Alvarez](/t5/user/viewprofilepage/user-id/5406700),

Welcome to Atlassian Community!

You cannot add new sections dynamically based on a number field the way you are describing. Those sections would have to already exist in the form for it to work. So lets say that you want to allow 1 - 10 passengers to be added, the you would have to have 10 sections defined in the form with identical fields.

comments: author: Manuel Alvarez
body: Hi [@Mikael Sandberg](/t5/user/viewprofilepage/user-id/853579) , thanks for the answer.

So the best solution would be having a final question after each section that triggers the unlocking of the following one.  

Like:  
Is there any passenger left?

* Yes
* No

Do you know how this would impact making API requests?  
For example the response would have a JSON structure nested by the section name?

something like this? but in a proper JSON structure?

```
section1:
  field1: value
  field2: value

section2:
  field1:value
  field2:value
```

Thanks again!


author: Mikael Sandberg
body: You cannot use the API to create requests that has a form attached to it. Form does have an API, but it does not allow you to create a new form and add responses to it.

Regarding the structure of the form you could add the yes/no question to each section, or you could have a single drop-down for the user to select the number of passengers, and based on that you activate each section, something like this:

![Screenshot 2024-01-16 at 9.29.48?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/300799i8DC2F94F1E37BEF3/image-size/large?v=v2&px=999 "Screenshot 2024-01-16 at 9.29.48?AM.png")

The first section would always be visible, and the following sections would conditionally visible based on the number of passengers selected above 1.


author: Sharon Comery
body: This was helpful for me, thank you :)

I added the sections as per your screen shots and in each section I put incremental tables which showed 1, 2, 3 etc rows depending on the number chosen in the conditional field.![Conditional tables.JPG](https://community.atlassian.com/t5/image/serverpage/image-id/345518iED93F5E7F30BAD35/image-size/large?v=v2&px=999 "Conditional tables.JPG")

A 3 rowed table shows because 3 was selected in the previous field.

![Conditional table 2.JPG](https://community.atlassian.com/t5/image/serverpage/image-id/345521i2F4EF836B99209E8/image-size/large?v=v2&px=999 "Conditional table 2.JPG")


Tags: cloud

jira-service-management

jira-service-management-cloud