<?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>Editable Grid from SQL</title><link>https://community.appian.com/discussions/f/data/19639/editable-grid-from-sql</link><description>I am very new to Appian and am trying to make an editable grid that pulls data from a SQL DB and then saves the changes back. I have created the Data Store and configured a Data Type, Expressions and Constants for each table.</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Editable Grid from SQL</title><link>https://community.appian.com/thread/76770?ContentTypeID=1</link><pubDate>Mon, 28 Sep 2020 18:32:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3560c2b1-33d8-4615-a0f6-a7ed96d4b5f9</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;For testing, in the interface designer when you utilize the &amp;quot;Test&amp;quot; button, plug your rule call into the expression for ri!data as:&amp;nbsp; =rule!Expression_cp_part(), you should see your grid load.&lt;/p&gt;
&lt;p&gt;Otherwise for the actual process, In your process model on the Data / Inputs tab of the User Input task, you should have a Node Input parameter for &amp;quot;data&amp;quot;.&amp;nbsp; For the &amp;quot;value&amp;quot; of data, the expression should read =rule!Expression_cp_part().&amp;nbsp; You will want to save this back into a process variable of type cp_part (multiple) to utilize in a following Write to Data Store Entity node.&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Editable Grid from SQL</title><link>https://community.appian.com/thread/76769?ContentTypeID=1</link><pubDate>Mon, 28 Sep 2020 18:20:41 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b1793cf2-8ca5-4ed2-aff6-93664407f6d2</guid><dc:creator>AllenP</dc:creator><description>&lt;p&gt;Doing something wrong still.&amp;nbsp; I created an expression:&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/16/pastedimage1601316841274v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Created an interface just trying to see if it would display data and nothing.&amp;nbsp; Not sure I am telling correctly where to pull the data from.&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/16/pastedimage1601317218768v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/16/pastedimage1601317249654v3.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Editable Grid from SQL</title><link>https://community.appian.com/thread/76765?ContentTypeID=1</link><pubDate>Mon, 28 Sep 2020 17:21:43 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d91b393f-3d74-40e0-b31c-a4a09a13937c</guid><dc:creator>AllenP</dc:creator><description>&lt;p&gt;Thank you Chris, I will give that a try&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Editable Grid from SQL</title><link>https://community.appian.com/thread/76761?ContentTypeID=1</link><pubDate>Mon, 28 Sep 2020 16:49:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ef151d9b-755c-455c-a8f2-dbd5f1a19863</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;For instance, a simple setup would contain 3 nodes in a process model.&amp;nbsp; Configure the process model to contain a process variable of your CDT type (multiple).&amp;nbsp; We&amp;#39;ll call it pv!data.&lt;/p&gt;
&lt;p&gt;Node 1, create a Script Task that utilizes an Output Expression to save a!queryEntity() from your data source into the pv!data variable, to be edited (best practice is to save this as a rule, then call the rule instead of a!queryEntity() directly):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;a!queryEntity(
  entity: cons!YOUR_DATA_ENTITY,
  query: a!query(
    pagingInfo: a!pagingInfo(1,-1),
    filter: a!queryFilter(
      field: &amp;quot;fieldToFilterOn&amp;quot;,
      operator: &amp;quot;=&amp;quot;,
      value: &amp;quot;filter Value&amp;quot;
    )
  )
).data&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Node 2, create an Interface and corresponding User Input Task, input will for pv!data, to send in your data to edit in the grid.&amp;nbsp; Here is the SAIL Recipe edited for a ri!data variable:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;
a!formLayout(
  label: &amp;quot;Example: Add,Update, or Remove Employee Data&amp;quot;,
  contents: {
    a!gridLayout(
      totalCount: count(ri!data),
      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: ri!data,
        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,
              placeholderLabel:  &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(ri!data, remove(ri!data, 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(ri!data, append(ri!data, save!value))
        }
      ),
      rowHeader: 1
    )
  },
  buttons: a!buttonLayout(
    primaryButtons: a!buttonWidget(
      label: &amp;quot;Submit&amp;quot;,
      submit: true
    )
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Editing the grid will update ri!data, which should save back into pv!data via the User Input Task configuration.&lt;/p&gt;
&lt;p&gt;Node 3, create a Write to Data Store node that is configured to write back to the DS in question here, with pv!data.&amp;nbsp; This will persist the prior User Input Task updates back to the DB.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Editable Grid from SQL</title><link>https://community.appian.com/thread/76755?ContentTypeID=1</link><pubDate>Mon, 28 Sep 2020 15:58:48 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:78e489d1-cb8d-45cc-a469-b6f24a981a11</guid><dc:creator>AllenP</dc:creator><description>&lt;p&gt;Thank you Chris.&amp;nbsp; I guess where I am lost is getting the data to display.&amp;nbsp; I am not understanding how to convert the link you attached from a local variable to the DB.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Editable Grid from SQL</title><link>https://community.appian.com/thread/76754?ContentTypeID=1</link><pubDate>Mon, 28 Sep 2020 15:44:57 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9d668da7-860c-43ed-8de8-0f773223f3a5</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;Feel free to add any details and/or code snippets here, such as - are you receiving an error?&amp;nbsp; Is data not populating in your grid?&amp;nbsp; Is data not saving back to the DB, etc?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Editable Grid from SQL</title><link>https://community.appian.com/thread/76753?ContentTypeID=1</link><pubDate>Mon, 28 Sep 2020 13:47:12 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c8147792-75f7-4b2c-b450-a7ffc75142bb</guid><dc:creator>AllenP</dc:creator><description>&lt;p&gt;Thank you for the welcome and the info.&amp;nbsp; I must be over looking something as I attempted this all weekend and still no luck.&amp;nbsp; I know I am missing something simple just can&amp;#39;t seem to put my finger on it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Editable Grid from SQL</title><link>https://community.appian.com/thread/76744?ContentTypeID=1</link><pubDate>Fri, 25 Sep 2020 20:04:40 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:bd484852-e496-41bd-b9d6-43567246593d</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;Welcome to the party Allen!&amp;nbsp; I would suggest first reviewing a bit of the documentation surrounding the functionality you are looking to implement.&amp;nbsp; As you build out your application, feel free to post any specific questions or errors here and we&amp;#39;ll be happy to assist.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.appian.com/suite/help/20.3/fnc_system_a_queryentity.html"&gt;a!queryEntity()&lt;/a&gt;&amp;nbsp;- retrieving the data to edit&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.appian.com/suite/help/20.3/recipe-add-edit-and-remove-data-in-an-inline-editable-grid.html"&gt;Editable Grids&lt;/a&gt;&amp;nbsp;- creating the update capability&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.appian.com/suite/help/20.3/Write_to_Data_Store_Entity_Smart_Service.html"&gt;Write to Data Store Entity&lt;/a&gt;&amp;nbsp;- persisting the updates back to SQL&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>