<?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>Adding rows to cdt</title><link>https://community.appian.com/discussions/f/general/33965/adding-rows-to-cdt</link><description>Hi Everyone, 
 I am getting the cdt rows through record type using expression rule. Is it possible to add more unique rows to cdt through expression rule. If yes, can anyone please help me out?</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Adding rows to cdt</title><link>https://community.appian.com/thread/129066?ContentTypeID=1</link><pubDate>Wed, 07 Feb 2024 05:22:36 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:dde68356-d9cd-4115-9d08-7eba9fcc071b</guid><dc:creator>SRINIVAS M</dc:creator><description>&lt;p&gt;Hi ,&lt;/p&gt;
&lt;p&gt;&lt;span&gt;you are currently retrieving existing CDT data via a record type using an expression rule.. To add new unique rows to this CDT, you can use the &lt;strong&gt;&lt;code&gt;append()&lt;/code&gt;&lt;/strong&gt; function within an expression rule to add new data to your existing dataset.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Steps:&lt;/span&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Retrieve Existing Data&lt;/strong&gt;: Use an expression rule to get the current rows of data from the CDT through the record type. Let&amp;#39;s assume this data is stored in a local variable called &lt;code&gt;local!existingData&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create New Row Data&lt;/strong&gt;: Define the new row data that you want to add to your CDT. This should match the structure of your CDT. For example:&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;local!newRow := {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;field1: &amp;quot;New Value 1&amp;quot;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;field2: &amp;quot;New Value 2&amp;quot;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;fieldN: &amp;quot;New Value N&amp;quot;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3.Add Row to Existing Data&lt;/strong&gt;&lt;span&gt;: Use the &lt;/span&gt;&lt;code&gt;append()&lt;/code&gt;&lt;span&gt; function to add your new row to the existing dataset:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; local!updatedData := append(local!existingData, local!newRow)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Save it.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Example:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;a!localVariables(&lt;br /&gt; local!existingData: /* Your expression to retrieve existing CDT data */,&lt;br /&gt; local!newRow: /* Define the new row data here */,&lt;br /&gt; local!updatedData: append(local!existingData, local!newRow),&lt;br /&gt; {&lt;br /&gt; /* Your interface elements go here, such as a grid or form to display local!existingData */&lt;br /&gt; /* Use a button or another interface component to trigger the save of local!updatedData */&lt;br /&gt; }&lt;br /&gt;)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding rows to cdt</title><link>https://community.appian.com/thread/129042?ContentTypeID=1</link><pubDate>Tue, 06 Feb 2024 19:15:38 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:88b25cea-7e26-4f95-aba9-309f723c0507</guid><dc:creator>Abhay Dalsaniya</dc:creator><description>&lt;p&gt;Not very clear on the ask, but if you are holding CDTs into a variable (array), you can use append() function as you use to add an element to an array.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding rows to cdt</title><link>https://community.appian.com/thread/129000?ContentTypeID=1</link><pubDate>Tue, 06 Feb 2024 12:10:17 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f56e41a4-c513-4a00-9e88-af8eee20e0a2</guid><dc:creator>Harshit Bumb (Appyzie)</dc:creator><description>&lt;p&gt;From what I understood, you can use the append() function and add as many rows as you want in the dataset queried from the record type.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding rows to cdt</title><link>https://community.appian.com/thread/128999?ContentTypeID=1</link><pubDate>Tue, 06 Feb 2024 11:49:20 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:25ea0c80-0ece-4984-ab4f-d3517ecc6040</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;We need more context to answer your question. A CDT is a data structure and does not have any &amp;quot;rows&amp;quot;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding rows to cdt</title><link>https://community.appian.com/thread/128998?ContentTypeID=1</link><pubDate>Tue, 06 Feb 2024 11:45:37 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:90c7491b-4301-400f-b62f-f765b6cdc53e</guid><dc:creator>Konduru Chaitanya</dc:creator><description>&lt;p&gt;Hello&amp;nbsp;&lt;a href="/members/shubhamy3376"&gt;Rahul009&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What do you mean by this?&lt;/p&gt;
[quote userid="201015" url="~/discussions/f/general/33965/adding-rows-to-cdt"]I am getting the cdt rows through record type using expression rule.[/quote]
&lt;p&gt;Are you saying that you are casting the data to RecordType?&lt;/p&gt;
&lt;p&gt;Try out the below code. As per my understanding, You are querying data from CDT and casting it to a recordType and using it in a grid. In the same grid you want to edit or add&amp;nbsp;the data and cast the data to CDT and save it using write to datastore entity. If yes, then this is the code.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!data: rule!yourQueryOfCDTToRecordData(),
  local!toCDT: a!forEach(
    items: local!data,
    expression: type!CDT(
      field1:&amp;quot;value&amp;quot;,
      field2:&amp;quot;value&amp;quot;,
      .
      .
      fieldn:&amp;quot;value&amp;quot;
    )
  ),
  {
    a!gridLayout(
      label: &amp;quot;Editable Grid&amp;quot;,
      labelPosition: &amp;quot;ABOVE&amp;quot;,
      headerCells: {
        a!gridLayoutHeaderCell(label: &amp;quot;Header Cell&amp;quot;),
        a!gridLayoutHeaderCell(label: &amp;quot;Header Cell&amp;quot;),
        a!gridLayoutHeaderCell(label: &amp;quot;Header Cell&amp;quot;),
        a!gridLayoutHeaderCell(label: &amp;quot;Header Cell&amp;quot;),
        a!gridLayoutHeaderCell(label: &amp;quot;Header Cell&amp;quot;)
      },
      columnConfigs: {
        a!gridLayoutColumnConfig(width: &amp;quot;DISTRIBUTE&amp;quot;),
        a!gridLayoutColumnConfig(width: &amp;quot;DISTRIBUTE&amp;quot;),
        a!gridLayoutColumnConfig(width: &amp;quot;DISTRIBUTE&amp;quot;),
        a!gridLayoutColumnConfig(width: &amp;quot;DISTRIBUTE&amp;quot;),
        a!gridLayoutColumnConfig(width: &amp;quot;DISTRIBUTE&amp;quot;)
      },
      rows: {
        a!forEach(
          items: local!data,
          expression: {
            a!gridRowLayout(
              contents: {
                a!textField(
                ),
                a!textField(
                ),
                a!textField(
                ),
                a!textField(
                ),
                a!textField(
                )
              }
            )
          }
        )
      },
      addRowLink: a!dynamicLink(
        label: &amp;quot;add Row&amp;quot;,
        value: null,
        saveInto: a!save(
          local!data,
          append(
            local!data,
            recordType!yourRecordType()
          )
        )
      ),
      selectionSaveInto: {},
      validations: {},
      shadeAlternateRows: true
    ),
    a!buttonArrayLayout(
      buttons: a!buttonWidget(saveInto: a!save(ri!myCDT, local!toCDT))
    )
  }
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>