<?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>Add new row  in the middle of the grid</title><link>https://community.appian.com/discussions/f/user-interface/39901/add-new-row-in-the-middle-of-the-grid</link><description>I have enhancement requirement , I have editable grid and when user add new row to the grid it should be inserted before the last row , Is that possible if yes can anyone help to get started with? 
 Below is my existing code</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Add new row  in the middle of the grid</title><link>https://community.appian.com/thread/152290?ContentTypeID=1</link><pubDate>Mon, 03 Nov 2025 11:10:16 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a3c62551-b27c-4c72-92ea-59105ab6fb35</guid><dc:creator>Harsha Sharma</dc:creator><description>&lt;p&gt;Oh yes insert() is great for this! can&amp;#39;t believe why my mind skipped it. Anyway glad you got the expected results.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Add new row  in the middle of the grid</title><link>https://community.appian.com/thread/152287?ContentTypeID=1</link><pubDate>Mon, 03 Nov 2025 10:11:08 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a9e0e23b-3f23-4f7b-ad93-42741ed8a016</guid><dc:creator>iswaryan3520</dc:creator><description>&lt;p&gt;Yes , insert works .&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Add new row  in the middle of the grid</title><link>https://community.appian.com/thread/152286?ContentTypeID=1</link><pubDate>Mon, 03 Nov 2025 10:02:55 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8c05195a-a2b4-4853-9332-255a058d7f61</guid><dc:creator>iswaryan3520</dc:creator><description>&lt;p&gt;Thanks , Harshitha . I will check this approach , tried with insert function it also seems to work for now.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Add new row  in the middle of the grid</title><link>https://community.appian.com/thread/152285?ContentTypeID=1</link><pubDate>Mon, 03 Nov 2025 09:33:51 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:21e05a64-c32e-40e1-a16c-ef08009f12ec</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;Did you try the insert() function?&lt;/p&gt;
&lt;p&gt;&lt;a id="" href="https://docs.appian.com/suite/help/25.3/fnc_array_insert.html"&gt;https://docs.appian.com/suite/help/25.3/fnc_array_insert.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Add new row  in the middle of the grid</title><link>https://community.appian.com/thread/152283?ContentTypeID=1</link><pubDate>Mon, 03 Nov 2025 09:27:25 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:83d25a3b-852c-4741-aa1a-d65eb7fa9c6d</guid><dc:creator>Harsha Sharma</dc:creator><description>&lt;p&gt;Making some tweaks to the expression for&amp;nbsp;addRowLink can help achieve the expected.&amp;nbsp;&lt;br /&gt;Here is a sample pattern you can refer which has two additional local variables and some changes to addRowLink definition so that expected functionality can be reached.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  /*  
  * local!employess is provided in this recipe as a way to start with hard-coded
  * data. However, this data is identical to the data created from the entity-backed
  * tutorial. Replace the hard-coded data with a query to the employee data store
  * entity and all of the employee records from the tutorial will appear.
  *
  * To replace this data with your own, replace (ctrl+H or cmd+H) all references to
  * local!employees with your data source, either via rule input or local variable.
  */
  local!employees: {
    a!map( id: 1, firstName: &amp;quot;John&amp;quot; , lastName: &amp;quot;Smith&amp;quot; , department: &amp;quot;Engineering&amp;quot; , title: &amp;quot;Director&amp;quot; , phoneNumber: &amp;quot;555-123-4567&amp;quot; , startDate: today()-360 ),
    a!map( id: 2, firstName: &amp;quot;Michael&amp;quot; , lastName: &amp;quot;Johnson&amp;quot; , department: &amp;quot;Finance&amp;quot; , title: &amp;quot;Analyst&amp;quot; , phoneNumber: &amp;quot;555-987-6543&amp;quot; , startDate: today()-360 ),
    a!map( id: 3, firstName: &amp;quot;Mary&amp;quot;, lastName: &amp;quot;Reed&amp;quot; , department: &amp;quot;Engineering&amp;quot; , title: &amp;quot;Software Engineer&amp;quot; , phoneNumber: &amp;quot;555-456-0123&amp;quot; , startDate: today()-240 ),
  },
 local!lastRow,local!newRow,
  a!formLayout(
    titleBar: &amp;quot;Example: Add,Update, or Remove Employee Data&amp;quot;,
    contents: {
      a!gridLayout(
        totalCount: count(local!employees),
        headerCells: {
          a!gridLayoutHeaderCell(label: &amp;quot;First Name&amp;quot; ),
          a!gridLayoutHeaderCell(label: &amp;quot;Last Name&amp;quot; ),
          a!gridLayoutHeaderCell(label: &amp;quot;Department&amp;quot; ),
          a!gridLayoutHeaderCell(label: &amp;quot;Title&amp;quot; ),
          a!gridLayoutHeaderCell(label: &amp;quot;Phone Number&amp;quot; ),
          a!gridLayoutHeaderCell(label: &amp;quot;Start Date&amp;quot;, align: &amp;quot;RIGHT&amp;quot; ),
          /* For the &amp;quot;Remove&amp;quot; column */
          a!gridLayoutHeaderCell(label: &amp;quot;&amp;quot; )
        },
        /* Only needed when some columns need to be narrow */
        columnConfigs: {
          a!gridLayoutColumnConfig(width: &amp;quot;DISTRIBUTE&amp;quot;, weight:3 ),
          a!gridLayoutColumnConfig(width: &amp;quot;DISTRIBUTE&amp;quot;, weight:3 ),
          a!gridLayoutColumnConfig(width: &amp;quot;DISTRIBUTE&amp;quot;, weight:3 ),
          a!gridLayoutColumnConfig(width: &amp;quot;DISTRIBUTE&amp;quot;, weight:3 ),
          a!gridLayoutColumnConfig(width: &amp;quot;DISTRIBUTE&amp;quot;, weight:3 ),
          a!gridLayoutColumnConfig(width: &amp;quot;DISTRIBUTE&amp;quot;, weight:2 ),
          a!gridLayoutColumnConfig(width: &amp;quot;ICON&amp;quot;)
        },
        /*
        * a!forEach() will take local!employee data and used that data to loop through an
        * expression that creates each row.
        *
        * When modifying the recipe to work with your data, you only need to change:
        * 1.) the number of fields in each row
        * 2.) the types of fields for each column (i.e. a!textField() for text data elements)
        * 3.) the fv!item elements. For example fv!item.firstName would change to fv!item.yourdata
        */
        rows: a!forEach(
          items: local!employees,
          expression: a!gridRowLayout(
            contents: {
              /* For the First Name Column*/
              a!textField(
                /* Labels are not visible in grid cells but are necessary to meet accessibility requirements */
                label: &amp;quot;first name &amp;quot; &amp;amp; fv!index,
                value: fv!item.firstName,
                saveInto: fv!item.firstName,
                required: true
              ),
              /* For the Last Name Column*/
              a!textField(
                label: &amp;quot;last name &amp;quot; &amp;amp; fv!index,
                value: fv!item.lastName,
                saveInto: fv!item.lastName,
                required:true
              ),
              /* For the Department Column*/
              a!dropdownField(
                label: &amp;quot;department &amp;quot; &amp;amp; fv!index,
                placeholder: &amp;quot;-- Select -- &amp;quot;,
                choiceLabels: { &amp;quot;Corporate&amp;quot;, &amp;quot;Engineering&amp;quot;, &amp;quot;Finance&amp;quot;, &amp;quot;Human Resources&amp;quot;, &amp;quot;Professional Services&amp;quot;, &amp;quot;Sales&amp;quot; },
                choiceValues: { &amp;quot;Corporate&amp;quot;, &amp;quot;Engineering&amp;quot;, &amp;quot;Finance&amp;quot;, &amp;quot;Human Resources&amp;quot;, &amp;quot;Professional Services&amp;quot;, &amp;quot;Sales&amp;quot; },
                value: fv!item.department,
                saveInto: fv!item.department,
                required:true
              ),
              /* For the Title Column*/
              a!textField(
                label: &amp;quot;title &amp;quot; &amp;amp; fv!index,
                value: fv!item.title,
                saveInto: fv!item.title,
                required:true
              ),
              /* For the Phone Number Column*/
              a!textField(
                label: &amp;quot;phone number &amp;quot; &amp;amp; fv!index,
                placeholder:&amp;quot;555-456-7890&amp;quot;,
                value: fv!item.phoneNumber,
                saveInto: fv!item.phoneNumber
              ),
              /* For the Start Date Column*/
              a!dateField(
                label: &amp;quot;start date &amp;quot; &amp;amp; fv!index,
                value: fv!item.startDate,
                saveInto: fv!item.startDate,
                required:true,
                align: &amp;quot;RIGHT&amp;quot;
              ),
              /* For the Removal Column*/
              a!richTextDisplayField(
                value: a!richTextIcon(
                  icon: &amp;quot;close&amp;quot;,
                  altText: &amp;quot;delete &amp;quot; &amp;amp; fv!index,
                  caption: &amp;quot;Remove &amp;quot; &amp;amp; fv!item.firstName &amp;amp; &amp;quot; &amp;quot; &amp;amp; fv!item.lastName,
                  link: a!dynamicLink(
                    value: fv!index,
                    saveInto: {
                      a!save(local!employees, remove(local!employees, save!value))
                    }
                  ),
                  linkStyle: &amp;quot;STANDALONE&amp;quot;,
                  color: &amp;quot;NEGATIVE&amp;quot;
                )
              )
            },
            id: fv!index
          )
        ),
        addRowlink: a!dynamicLink(
          label: &amp;quot;Add Employee&amp;quot;,
          /*
           * For your use case, set the value to a blank instance of your CDT using
           * the type constructor, e.g. type!Employee(). Only specify the field
           * if you want to give it a default value e.g. startDate: today()+1.
           */
          value: {
            startDate: today() + 1
          },
          saveInto: {
            a!save(local!lastRow,local!employees[length(local!employees)]),
            a!save(local!employees, append(local!employees, save!value)),
            
            a!save(local!newRow,save!value),
            a!save(local!employees,a!update(
              local!employees,{length(local!employees),length(local!employees)-1},
              {local!lastRow,local!newRow}))
            
            
          }
        ),
        rowHeader: 1
      )
    },
    buttons: a!buttonLayout(
      primaryButtons: a!buttonWidget(
        label: &amp;quot;Submit&amp;quot;,
        submit: true
      )
    )
  )
)
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>