<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Duplicating Section layout on button click</title><link>https://community.appian.com/discussions/f/general/29054/duplicating-section-layout-on-button-click</link><description>Hi, I have a requirement where I need to duplicate a particular section on clicking add button. In the section I have some text fields and clicking on the &amp;quot;Add&amp;quot; button the text fields should get duplicated where I have to enter new values in the field</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Duplicating Section layout on button click</title><link>https://community.appian.com/thread/116568?ContentTypeID=1</link><pubDate>Thu, 20 Jul 2023 16:40:25 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:11be9e00-f971-4360-95c7-27ca196f31d9</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;This really depends on what&amp;#39;s happening upon click of &amp;quot;Add subsection&amp;quot;, and whether it&amp;#39;s handling the internal data correctly, which we can&amp;#39;t possibly hope to discern (or even make presumptive guesses at) with only a top-level screenshot, unfortunately.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicating Section layout on button click</title><link>https://community.appian.com/thread/116567?ContentTypeID=1</link><pubDate>Thu, 20 Jul 2023 16:35:25 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:86a4f81d-641f-4bbf-a274-7525be7ac6c8</guid><dc:creator>srinivaasant574373</dc:creator><description>&lt;p&gt;In the same case now, I have nested foreach loops. I have CDT relation between parent section and child section. I have &lt;strong&gt;Add&amp;nbsp;&lt;/strong&gt;&lt;b&gt;subsection&lt;/b&gt;&amp;nbsp;button where I can add multiple sections inside a section. In the image &amp;quot;name&amp;quot; field which is highlighted will be repeated if we click &amp;quot;Add Subsection&amp;quot; button. I need to store the name value in the parent CDT . I have one to many relationship in this case. Only the field which I established relationship inside a&amp;nbsp; parent CDT should get added. But entire CDT is getting added and the value is saved separately.Could you please help me with this.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/11/2287.appian.PNG" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicating Section layout on button click</title><link>https://community.appian.com/thread/114838?ContentTypeID=1</link><pubDate>Thu, 22 Jun 2023 16:35:23 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:96cda5cb-ccca-4398-9684-de4dd916ed03</guid><dc:creator>sanchitg0002</dc:creator><description>&lt;p&gt;Pass an empty CDT instance using type!CDT() in ri!test wherever you are calling this interface and for testing, set a default value.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicating Section layout on button click</title><link>https://community.appian.com/thread/114824?ContentTypeID=1</link><pubDate>Thu, 22 Jun 2023 14:53:07 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:282b8a90-5ae2-4515-8160-f91235470eb2</guid><dc:creator>srinivaasant574373</dc:creator><description>&lt;p&gt;By default I need to show one section in the UI . But by using this code only on clicking the add button the section is visible. Could you please help me on that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicating Section layout on button click</title><link>https://community.appian.com/thread/114783?ContentTypeID=1</link><pubDate>Thu, 22 Jun 2023 11:41:40 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:96e9bb3f-a795-4d04-97de-89fb51ad44b0</guid><dc:creator>sanchitg0002</dc:creator><description>&lt;p&gt;You can form the loop on ri!test and with some changes in a!save() it should work, make sure that ri!test is of array type.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!localVariables(
  {
    a!sectionLayout(
      label: &amp;quot;Primary&amp;quot;,
      contents: {
        a!forEach(
          ri!test,
          a!sectionLayout(
            label: &amp;quot;Section&amp;quot;,
            contents: {
              a!columnsLayout(
                columns: {
                  a!columnLayout(
                    contents: {
                      a!textField(
                        label: &amp;quot;Text&amp;quot;,
                        labelPosition: &amp;quot;ABOVE&amp;quot;,
                        value: fv!item.caseType,
                        saveInto: { fv!item.caseType },
                        refreshAfter: &amp;quot;UNFOCUS&amp;quot;,
                        validations: {}
                      )
                    }
                  ),
                  a!columnLayout(
                    contents: {
                      a!textField(
                        label: &amp;quot;Text&amp;quot;,
                        labelPosition: &amp;quot;ABOVE&amp;quot;,
                        value: fv!item.count,
                        saveInto: { fv!item.count },
                        refreshAfter: &amp;quot;UNFOCUS&amp;quot;,
                        validations: {}
                      )
                    }
                  ),
                  a!columnLayout(contents: {})
                }
              ),
              a!buttonArrayLayout(
                buttons: {
                  a!buttonWidget(
                    label: &amp;quot;Remove&amp;quot;,
                    style: &amp;quot;NORMAL&amp;quot;,
                    saveInto: {
                      a!save(ri!test, remove(ri!test, fv!index))
                    }
                  )
                },
                align: &amp;quot;START&amp;quot;
              )
            }
          )
        )
      }
    ),
    a!buttonArrayLayout(
      buttons: {
        a!buttonWidget(
          label: &amp;quot;Add Section&amp;quot;,
          style: &amp;quot;NORMAL&amp;quot;,
          saveInto: {
            a!save(ri!test, append(ri!test, type!CDTname))
          }
        )
      },
      align: &amp;quot;START&amp;quot;
    )
  }
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Replace type! at line:63 with actual CDT name.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicating Section layout on button click</title><link>https://community.appian.com/thread/114778?ContentTypeID=1</link><pubDate>Thu, 22 Jun 2023 10:52:04 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9d8ecbb6-ff2f-4aec-a30c-137d3a151ae1</guid><dc:creator>srinivaasant574373</dc:creator><description>&lt;p&gt;I need to store the field values of each section as an array . But I am getting some error in value parameter. Should we use &amp;quot;item&amp;quot; in foreach loop?&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!count: 1,
{
  a!sectionLayout(
    label: &amp;quot;Primary&amp;quot;,
    contents: {
      a!forEach(
        enumerate(local!count),
      a!sectionLayout(
        label: &amp;quot;Section&amp;quot;,
        contents: {
          a!columnsLayout(
            columns: {
              a!columnLayout(
                contents: {
                  a!textField(
                    label: &amp;quot;Text&amp;quot;,
                    labelPosition: &amp;quot;ABOVE&amp;quot;,
                    /*value: ri!test.casetype,*/
                    saveInto: {ri!test.casetype},
                    refreshAfter: &amp;quot;UNFOCUS&amp;quot;,
                    validations: {}
                  )
                }
              ),
              a!columnLayout(
                contents: {
                  a!textField(
                    label: &amp;quot;Text&amp;quot;,
                    labelPosition: &amp;quot;ABOVE&amp;quot;,
                    /*value: ri!test.count,*/
                    saveInto: {ri!test.count},
                    refreshAfter: &amp;quot;UNFOCUS&amp;quot;,
                    validations: {}
                  )
                }
              ),
              a!columnLayout(
                contents: {}
              )
            }
          ),
          a!buttonArrayLayout(
            buttons: {
              a!buttonWidget(
                label: &amp;quot;Remove&amp;quot;,
                style: &amp;quot;NORMAL&amp;quot;,
                saveInto: a!save(local!count, local!count - 1)
              )
            },
            align: &amp;quot;START&amp;quot;
          )
        }
      ))
    }
  ),
  a!buttonArrayLayout(
    buttons: {
      a!buttonWidget(
        label: &amp;quot;Add Section&amp;quot;,
        style: &amp;quot;NORMAL&amp;quot;,
        saveInto: a!save(local!count, local!count + 1)
      )
    },
    align: &amp;quot;START&amp;quot;
  )
}
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicating Section layout on button click</title><link>https://community.appian.com/thread/114695?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2023 09:43:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b19ca96f-f5bf-4746-84e3-3abf8b4d7ec8</guid><dc:creator>Harshit Bumb (Appyzie)</dc:creator><description>&lt;p&gt;Please consider accepting the answer so if any one else is facing the same issue, they can look at the solution that was working.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicating Section layout on button click</title><link>https://community.appian.com/thread/114694?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2023 09:39:36 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:84f18397-d826-46b7-b14b-caf4ef7e8cbb</guid><dc:creator>srinivaasant574373</dc:creator><description>&lt;p&gt;Thank you Very much&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicating Section layout on button click</title><link>https://community.appian.com/thread/114692?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2023 08:41:08 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a3a46ad0-fddb-4255-b525-746aa70e8a87</guid><dc:creator>sanchitg0002</dc:creator><description>&lt;p&gt;You can achieve this with the help of a!forEach()&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Example:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!localVariables(
  local!count: 1,
  {
    a!forEach(
      enumerate(local!count),
      a!sectionLayout(
        label: &amp;quot;Section&amp;quot;,
        contents: {
          a!textField(
            label: &amp;quot;Text&amp;quot;,
            labelPosition: &amp;quot;ABOVE&amp;quot;,
            saveInto: {},
            refreshAfter: &amp;quot;UNFOCUS&amp;quot;,
            validations: {}
          )
        }
      )
    ),
    a!buttonArrayLayout(
      buttons: {
        a!buttonWidget(
          label: &amp;quot;Add Section&amp;quot;,
          style: &amp;quot;NORMAL&amp;quot;,
          saveInto: a!save(local!count, local!count + 1)
        )
      },
      align: &amp;quot;START&amp;quot;
    )
  }
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>