<?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>Expand and Collapse with Selection option</title><link>https://community.appian.com/discussions/f/new-to-appian/27935/expand-and-collapse-with-selection-option</link><description>Hi 
 I am trying to emulate the &amp;#39;Corporate Raffle&amp;#39; tutorial in Appian with some changes in the requirements. I have to show a &amp;#39;details&amp;#39; section within the &amp;#39;summary&amp;#39; section. If user selects an item, product id and product description information has to</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Expand and Collapse with Selection option</title><link>https://community.appian.com/thread/108646?ContentTypeID=1</link><pubDate>Wed, 01 Mar 2023 05:05:49 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a715ae9d-2b9c-4899-b49c-e649611f5cfc</guid><dc:creator>Naresh</dc:creator><description>&lt;p&gt;Hi, here is the code for your ask.&lt;/p&gt;
&lt;p&gt;Note: This is not an optimized code, I just updated your code for&amp;nbsp;your&amp;nbsp;requirement.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="xml"&gt;a!localVariables(
  /*--- start of localVariables */
  local!pageHeaderTextColor: &amp;quot;#44546A&amp;quot;,
  local!sectionDividerColor: &amp;quot;#333F50&amp;quot;,
  local!selectedIndex,
  local!selectedProduct,
  local!dataSummary: {
    {
      productId: &amp;quot;123&amp;quot;,
      productDesc: &amp;quot;item Apple&amp;quot;
    },
    {
      productId: &amp;quot;456&amp;quot;,
      productDesc: &amp;quot;item Basketball&amp;quot;
    },
    {
      productId: &amp;quot;789&amp;quot;,
      productDesc: &amp;quot;item Computer&amp;quot;
    }
  },
  local!dataDetail: {
    {
      productId: &amp;quot;123&amp;quot;,
      brandOwner: &amp;quot;Apple Farmer Inc.&amp;quot;,
      State: &amp;quot;NY&amp;quot;,
      Zip: &amp;quot;12345&amp;quot;
    },
    {
      productId: &amp;quot;456&amp;quot;,
      brandOwner: &amp;quot;Nike Inc.&amp;quot;,
      State: &amp;quot;OR&amp;quot;,
      Zip: &amp;quot;97075&amp;quot;
    },
    {
      productId: &amp;quot;789&amp;quot;,
      brandOwner: &amp;quot;AST Computers&amp;quot;,
      State: &amp;quot;CA&amp;quot;,
      Zip: &amp;quot;90005&amp;quot;
    }
  },
  {
    /*--- start of two columns ---*/
    a!columnsLayout(
      columns: {
        a!columnLayout(            /*--- start of product list column ---*/
          width: &amp;quot;3X&amp;quot;,
          contents: {
            a!sectionLayout(
              divider:&amp;quot;BELOW&amp;quot;,
              dividerColor: local!sectionDividerColor,
              dividerWeight: &amp;quot;MEDIUM&amp;quot;,
              /*--- section for selected product section layout ---*/
              label: &amp;quot;Products List&amp;quot;,
              labelSize: &amp;quot;LARGE&amp;quot;,
              labelHeadingTag: &amp;quot;H1&amp;quot;,
              labelColor: local!pageHeaderTextColor,
              contents: {}
            ), /*--- section to display selected products ---*/
            /*--- start of interface ---*/
            a!sectionLayout(
              contents: a!forEach(
                items: local!dataSummary,
                expression: {
                  a!cardLayout(
                    contents: {
                      a!sideBySideLayout(
                        items: {
                          a!sideBySideItem(
                            item: a!richTextDisplayField(
                              labelPosition: &amp;quot;COLLAPSED&amp;quot;,
                              value: {
                                a!richTextIcon(
                                  icon: &amp;quot;square-o&amp;quot;,
                                  link: a!dynamicLink(
                                    saveInto: {
                                      a!save(local!selectedIndex, fv!index),
                                      a!save(local!selectedProduct, fv!item)
                                    }
                                  ),
                                  linkStyle: &amp;quot;STANDALONE&amp;quot;,
                                  showWhen: tointeger(local!selectedIndex) &amp;lt;&amp;gt; fv!index,
                                  size: &amp;quot;MEDIUM&amp;quot;
                                ),
                                a!richTextIcon(
                                  icon: &amp;quot;check-square-o-alt&amp;quot;,
                                  link: a!dynamicLink(
                                    saveInto: {
                                      a!save(
                                        {local!selectedIndex, local!selectedProduct},
                                        null
                                      )
                                    }
                                  ),
                                  linkStyle: &amp;quot;STANDALONE&amp;quot;,
                                  showWhen: tointeger(local!selectedIndex) = fv!index,
                                  size: &amp;quot;MEDIUM&amp;quot;
                                )
                              },
                              align: &amp;quot;LEFT&amp;quot;
                            )
                          ),
                          a!sideBySideItem(
                            item: a!richTextDisplayField(
                              labelPosition: &amp;quot;COLLAPSED&amp;quot;,
                              value: {
                                a!richTextItem(
                                  text: local!dataSummary[fv!index].productId,
                                  size: &amp;quot;MEDIUM&amp;quot;,
                                  style: &amp;quot;STRONG&amp;quot;
                                ),
                                char(10),
                                a!richTextItem(
                                  text: local!dataSummary[fv!index].productDesc
                                )
                              },
                              align: &amp;quot;RIGHT&amp;quot;
                            )
                          )
                        },
                        alignVertical: &amp;quot;MIDDLE&amp;quot;
                      ),
                      a!sectionLayout(
                        /*--- start of sectionLayout - product details ---*/
                        label: &amp;quot;Show Product Details&amp;quot;,
                        labelSize: &amp;quot;SMALL&amp;quot;,
                        labelHeadingTag: &amp;quot;H2&amp;quot;,
                        contents: {
                          a!sideBySideLayout(
                            /*--- product details ---*/
                            items: {
                              a!sideBySideItem(
                                item: a!textField(
                                  label: &amp;quot;Product ID&amp;quot;,
                                  labelPosition: &amp;quot;COLLAPSED&amp;quot;,
                                  value: local!dataDetail[fv!index].productId,
                                  readOnly: true
                                )
                              ),
                              a!sideBySideItem(
                                item: a!textField(
                                  label: &amp;quot;Manufacturer&amp;quot;,
                                  labelPosition: &amp;quot;COLLAPSED&amp;quot;,
                                  value: local!dataDetail[fv!index].brandOwner,
                                  readOnly: true
                                )
                              ),
                              a!sideBySideItem(
                                item: a!textField(
                                  label: &amp;quot;State&amp;quot;,
                                  labelPosition: &amp;quot;COLLAPSED&amp;quot;,
                                  value: local!dataDetail[fv!index].State,
                                  readOnly: true
                                )
                              ),
                              a!sideBySideItem(
                                item: a!textField(
                                  label: &amp;quot;Zipcode&amp;quot;,
                                  labelPosition: &amp;quot;COLLAPSED&amp;quot;,
                                  value: local!dataDetail[fv!index].Zip,
                                  readOnly: true
                                )
                              )
                            },
                            /*showWhen:local!isDetailVisible,*/
                            marginAbove: &amp;quot;STANDARD&amp;quot;
                          )/*--- end of product summary sideByside layout */

                        },
                        isCollapsible: true()
                      )/*--- end of sectionLayout - product details ---*/

                    },
                    /*--- end of contents for cardLayout ---*/
                    height: &amp;quot;AUTO&amp;quot;,
                    shape: &amp;quot;SEMI_ROUNDED&amp;quot;,
                    marginBelow: &amp;quot;NONE&amp;quot;
                  )/*--- end of main section cardLayout ---*/                  
                }/*--- end of expression attribute of forEach ---*/                
              ),
              /*--- closing forEach/main sectionLayout --*/
            )/*--- end of top-level section layout ---*/

          }/*--- matches with start of interface section ---*/
        ),
        /*--- end of product list columnsLayout ---*/
        a!columnLayout(  /*--- column to display selected products ---*/
          width: &amp;quot;1X&amp;quot;,
          contents: {
            a!sectionLayout(
              divider:&amp;quot;BELOW&amp;quot;,
              dividerColor: local!sectionDividerColor,
              dividerWeight: &amp;quot;MEDIUM&amp;quot;,
              /*--- section for selected product section layout ---*/
              label: &amp;quot;Selection&amp;quot;,
              labelSize: &amp;quot;LARGE&amp;quot;,
              labelHeadingTag: &amp;quot;H1&amp;quot;,
              labelColor: local!pageHeaderTextColor,
              contents: {
                a!sideBySideLayout(
                  showWhen: a!isNotNullOrEmpty(local!selectedProduct),
                  items: {
                    a!sideBySideItem(
                      item: a!richTextDisplayField(
                        label: &amp;quot;Product ID&amp;quot;,
                        value: local!selectedProduct.productId
                      )
                    ),
                    a!sideBySideItem(
                      item: a!richTextDisplayField(
                        label: &amp;quot;Product Description&amp;quot;,
                        value: local!selectedProduct.productDesc
                      )
                    )
                  }
                )
              }
            )/*--- section to display selected products ---*/

          }, /*--- start of selected product column --*/

        )
      }/*--- end of two columns ---*/

    )
  }
)/*--- matches with start of localVariables ---*/&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>