Want to Repeat an section on click of button .

Section might contain the fields like dropdown, flieupload ,.. those should also get repeated 

  Discussion posts and replies are publicly visible

  • 0
    Certified Associate Developer

    Hii  , can you please explain more about your use case.

  • Hello, I'm not sure if this is what you are looking for but I'll give it a try.

    I imagine you are working with an array of something, like a CDT or Record Type.

    What I would do is to have that array as rule input / local variable and then do a forEach() over it. Inside the forEach() you would put whatever fields you want (even as a section as you mentioned).

    To add more instances of that section, you'd create a button that would append an empty value (CDT or Record Type) to your variable. This way the fields/section is going to be repeated:

    (...)saveInto: a!save(
        ri!variable,
        append(
            ri!variable,
            type!CDT()
        )
    )

  • +1
    Certified Lead Developer

    Here's a basic example, you should be able to swap in your type! values and configure your components

    a!localVariables(
      local!someVar,
      {
        a!forEach(
          items: local!someVar,
          expression: a!sectionLayout(
            label: "Section: " & fv!index,
            divider: "ABOVE",
            contents: {
              a!textField(
                label: "Name",
                value: fv!item.name,
                saveInto: fv!item.name
              ),
              a!dateField(
                label: "DoB",
                value: fv!item.dob,
                saveInto: fv!item.dob
              )
            }
          )
        ),
        a!buttonArrayLayout(
          buttons: {
            a!buttonWidget(
              icon: "plus",
              label: "Add Row",
              value: a!map(name: null, dob: null),
              saveInto: a!save(
                target: local!someVar,
                value: append(local!someVar, save!value)
              )
            )
          }
        )
      }
    )