<?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>Problem of saving updated grid field in database</title><link>https://community.appian.com/discussions/f/rules/20174/problem-of-saving-updated-grid-field-in-database</link><description>Here is my code. I have one editable grid in which one priority field is there: 
 a!integerField( label: &amp;quot;Priority&amp;quot;, labelPosition: &amp;quot;ABOVE&amp;quot;, value: if(not(isnull(fv!item.priority)),int(fv!item.priority)-rule!CRP_CheckPriority(fv!item.priority,fv!item</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Problem of saving updated grid field in database</title><link>https://community.appian.com/thread/78822?ContentTypeID=1</link><pubDate>Fri, 08 Jan 2021 17:09:32 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:2d630405-702f-4d22-b862-98ca4248e06e</guid><dc:creator>dhavalp0001</dc:creator><description>&lt;p&gt;Thanks Peter it works and i got my solution. Thanks for Help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem of saving updated grid field in database</title><link>https://community.appian.com/thread/78817?ContentTypeID=1</link><pubDate>Fri, 08 Jan 2021 13:57:52 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ab99c10c-d320-480e-aaea-61301459b6cb</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;Ok this looks ok to me - how are you then saving the data to the database? Do you have a button that on save transfers the values from local!dataUpdated to a rule input?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem of saving updated grid field in database</title><link>https://community.appian.com/thread/78815?ContentTypeID=1</link><pubDate>Fri, 08 Jan 2021 04:57:38 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:57ad7755-3645-4e1e-8882-0db92dfbd1c5</guid><dc:creator>dhavalp0001</dc:creator><description>&lt;p&gt;here local!items are like local!data in your code and then i define local!dataUpdated as you said and then in gridlayout see priority field . i want priority new value should be saved .&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem of saving updated grid field in database</title><link>https://community.appian.com/thread/78814?ContentTypeID=1</link><pubDate>Fri, 08 Jan 2021 04:56:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1af156e9-14ea-4114-9dd1-38bec0920366</guid><dc:creator>dhavalp0001</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt; local!items: { rule!CRP_Dashboard1(local!status{},local!contentdomain{},local!priority,local!businessunit1{}, if (and(not(isnull(local!modeler)),length(local!modeler)&amp;gt;0), user(usersearch({&amp;quot;firstName&amp;quot;,&amp;quot;lastName&amp;quot;},{1,1},split(local!modeler,&amp;quot; &amp;quot;)[1], split(local!modeler,&amp;quot; &amp;quot;)[2]),&amp;quot;username&amp;quot;), &amp;quot;&amp;quot; ), if (and(not(isnull(local!contentowner)),length(local!contentowner)&amp;gt;0), user(usersearch({&amp;quot;firstName&amp;quot;,&amp;quot;lastName&amp;quot;},{1,1},split(local!contentowner,&amp;quot; &amp;quot;)[1], split(local!contentowner,&amp;quot; &amp;quot;)[2]),&amp;quot;username&amp;quot;), &amp;quot;&amp;quot; ),if (and(not(isnull(local!createdby)),length(local!createdby)&amp;gt;0), user(usersearch({&amp;quot;firstName&amp;quot;,&amp;quot;lastName&amp;quot;},{1,1},split(local!createdby,&amp;quot; &amp;quot;)[1], split(local!createdby,&amp;quot; &amp;quot;)[2]),&amp;quot;username&amp;quot;), &amp;quot;&amp;quot; ),local!search,local!department,local!pathvalue).data},
  local!dataUpdated: a!forEach(
    items: local!items,
    expression: a!map(
      id: fv!item.id,
      fteSaving: fv!item.fteSaving,
      status:fv!item.status,
      contentdomain:fv!item.contentdomain,
      priority:if(not(isnull(fv!item.priority)),int(fv!item.priority)-rule!CRP_CheckPriority(fv!item.priority,fv!item.contentdomain),fv!item.priority),
      dateofCompletion:fv!item.dateofCompletion,
      percentageCompleted:fv!item.percentageCompleted,
      comment:fv!item.comment
    )
  ),
  
  a!gridLayout(
        label: &amp;quot;Project List&amp;quot;,
        labelPosition: &amp;quot;ABOVE&amp;quot;,
        headerCells: {
          a!gridLayoutHeaderCell(label: &amp;quot;Reference ID&amp;quot;),
          a!gridLayoutHeaderCell(label: &amp;quot;Project Name&amp;quot;),
          a!gridLayoutHeaderCell(label: &amp;quot;FTE Savings&amp;quot;),
          a!gridLayoutHeaderCell(label: &amp;quot;Project Status&amp;quot;),
          a!gridLayoutHeaderCell(label: &amp;quot;Content Domain&amp;quot;),
          /*a!gridLayoutHeaderCell(label: &amp;quot;Robotics Owner&amp;quot;),*/
          a!gridLayoutHeaderCell(label: &amp;quot;Priority&amp;quot;),
          a!gridLayoutHeaderCell(label: &amp;quot;Date Of Completion&amp;quot;),
          a!gridLayoutHeaderCell(label: &amp;quot;% Completed&amp;quot;),
          a!gridLayoutHeaderCell(label: &amp;quot;Comment&amp;quot;)
          
        },
        columnConfigs: {},
        rows: a!forEach(
          items: local!dataUpdated,
          expression: a!gridRowLayout(
            contents: {
              
              a!textField(
                label: &amp;quot;Reference ID&amp;quot;,
                labelPosition: &amp;quot;ABOVE&amp;quot;,
                value: rule!CRP_getReferenceIdForRequests(fv!item.id),
                saveInto: {},
                refreshAfter: &amp;quot;UNFOCUS&amp;quot;,
                readOnly: true,
                validations: {}
                
              ),
              /*a!textField(*/
                /*label: &amp;quot;Project Name&amp;quot;,*/
                /*labelPosition: &amp;quot;ABOVE&amp;quot;,*/
                /*value: fv!item.projectName,*/
                /*saveInto: {},*/
                /*refreshAfter: &amp;quot;UNFOCUS&amp;quot;,*/
                /*readOnly: true,*/
                /*validations: {}*/
/*                */
              /*),*/
              a!linkField(
                label:&amp;quot;Project Name&amp;quot;,
                links: {
                  a!recordLink(
                    label:fv!item.projectName,
                    recordType:&amp;#39;recordType!{953256b7-ada0-4458-9e7d-4827957f243d}Automation Project Inventory&amp;#39;,
                    identifier: fv!item.id
                  )
                }
              ),
             
              a!textField(
                label: &amp;quot;FTE Savings&amp;quot;,
                labelPosition: &amp;quot;ABOVE&amp;quot;,
                value: fv!item.fteSaving,
                saveInto: {},
                refreshAfter: &amp;quot;UNFOCUS&amp;quot;,
                readOnly: true,
                validations: {}
              ),
              a!textField(
                label: &amp;quot;Status&amp;quot;,
                labelPosition: &amp;quot;ABOVE&amp;quot;,
                value: rule!CRP_GetStatusbyid(fv!item.status),
                saveInto: {},
                refreshAfter: &amp;quot;UNFOCUS&amp;quot;,
                readOnly: true,
                validations: {}
              ),
              a!textField(
                label: &amp;quot;Content Domain&amp;quot;,
                labelPosition: &amp;quot;ABOVE&amp;quot;,
                value: rule!CRP_GetContentDomainbyid(fv!item.contentdomain),
                saveInto: {},
                refreshAfter: &amp;quot;UNFOCUS&amp;quot;,
                readOnly: true,
                validations: {}
              ),
             
              /*a!linkField(*/
                /*label: &amp;quot;Robotics Owner&amp;quot;,*/
                /*labelPosition: &amp;quot;ABOVE&amp;quot;,*/
                /*links: {*/
                  /*a!userRecordLink(*/
                    /*label: rule!CRP_FormatName(fv!item.roboticsOwner),*/
                    /*user: fv!item.roboticsOwner*/
                  /*)*/
                /*}*/
                /*,*/
                /*readOnly: true*/
              /*),*/
              a!integerField(
                label: &amp;quot;Priority&amp;quot;,
                labelPosition: &amp;quot;ABOVE&amp;quot;,
                value: fv!item.priority,
                saveInto: {a!save(fv!item.priority,save!value)
                
                
                },
                refreshAfter: &amp;quot;UNFOCUS&amp;quot;,
                readOnly: if(local!gridreadonly=&amp;quot;Edit&amp;quot;,true,false),
                validations: {if(and(local!gridreadonly=&amp;quot;Save&amp;quot;,not (isnull(fv!item.priority))),{if(count(rule!CRP_GetPriority(priority: fv!item.priority,contentdomain: fv!item.contentdomain,id:fv!item.id)) &amp;gt;0,&amp;quot;This Priority is already assigned to other Project..&amp;quot;,null)},{}),
                if(and(not (isnull(fv!item.priority)),int(fv!item.priority)&amp;gt;10),&amp;quot;Priority must be between 1 and 10&amp;quot;,&amp;quot;&amp;quot;)}
                
              ),
              a!dateField(
                label: &amp;quot;Date Of Completion&amp;quot;,
                labelPosition: &amp;quot;ABOVE&amp;quot;,
                value: fv!item.dateofCompletion,
                saveInto: a!save(fv!item.dateofCompletion,save!value),                
                refreshAfter: &amp;quot;UNFOCUS&amp;quot;,
                readOnly: if(local!gridreadonly=&amp;quot;Edit&amp;quot;,true,false)
                

              ),
              a!integerField(
                label: &amp;quot;% Completed&amp;quot;,
                labelPosition: &amp;quot;ABOVE&amp;quot;,
                value: fv!item.percentageCompleted,
                saveInto: a!save(fv!item.percentageCompleted,save!value),                
                refreshAfter: &amp;quot;UNFOCUS&amp;quot;,
                readOnly: if(local!gridreadonly=&amp;quot;Edit&amp;quot;,true,false)
                

              ),
              a!textField(
                label: &amp;quot;Comment&amp;quot;,
                labelPosition: &amp;quot;ABOVE&amp;quot;,
                value: fv!item.comment,
                saveInto: a!save(fv!item.comment,save!value),                
                
                readOnly: if(local!gridreadonly=&amp;quot;Edit&amp;quot;,true,false)
                

              )
            }
          )
        )
      )&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem of saving updated grid field in database</title><link>https://community.appian.com/thread/78805?ContentTypeID=1</link><pubDate>Thu, 07 Jan 2021 18:45:50 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ead05997-1cf2-4839-a3b7-1f409204b950</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;I&amp;#39;m sorry, I don&amp;#39;t follow what you&amp;#39;re saying - was there a bug with inserting the code? Is it too many lines? If it&amp;#39;s too long an interface, just seeing how you defined your local variable that you&amp;#39;re looping over should help us troubleshoot.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem of saving updated grid field in database</title><link>https://community.appian.com/thread/78802?ContentTypeID=1</link><pubDate>Thu, 07 Jan 2021 17:55:50 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e43031db-c202-4592-9ef9-1d92a23941f8</guid><dc:creator>dhavalp0001</dc:creator><description>&lt;p&gt;I have inserted code but it couldn&amp;#39;t be seen here.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem of saving updated grid field in database</title><link>https://community.appian.com/thread/78799?ContentTypeID=1</link><pubDate>Thu, 07 Jan 2021 17:47:07 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:212360cb-65c8-4bf3-8739-14431ccee90c</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;Can you post the full SAIL code for your interface? Please use the insert &amp;gt; code option so we can easily read it!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem of saving updated grid field in database</title><link>https://community.appian.com/thread/78798?ContentTypeID=1</link><pubDate>Thu, 07 Jan 2021 17:45:15 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:adb90786-2f4a-4be8-9197-5ea7bd29a586</guid><dc:creator>dhavalp0001</dc:creator><description>&lt;p&gt;No still not saved.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem of saving updated grid field in database</title><link>https://community.appian.com/thread/78795?ContentTypeID=1</link><pubDate>Thu, 07 Jan 2021 14:31:41 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:affe9a9b-d3ec-4430-aead-852671060192</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;You have to define the data before you even get to the grid. Here&amp;#39;s an example:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!data: {
    a!map(
      id: 1,
      name: &amp;quot;Test&amp;quot;,
      value: &amp;quot;&amp;quot;
    ),
    a!map(
      id: 2,
      name: &amp;quot;Test Again&amp;quot;,
      value: &amp;quot;&amp;quot;
    )
  },
  local!dataUpdated: a!forEach(
    items: local!data,
    expression: a!map(
      id: fv!item.id,
      name: fv!item.name,
      value: &amp;quot;New Value&amp;quot;
    )
  ),
  a!gridLayout(
    headerCells: {
      a!gridLayoutHeaderCell(label: &amp;quot;ID&amp;quot;),
      a!gridLayoutHeaderCell(label: &amp;quot;Name&amp;quot;),
      a!gridLayoutHeaderCell(label: &amp;quot;Value&amp;quot;),
    },
    rows: a!forEach(
      items: local!dataUpdated,
      expression: a!gridRowLayout(
        contents: {
          a!textField(
            value: fv!item.id,
            saveInto: fv!item.id
          ),
          a!textField(
            value: fv!item.name,
            saveInto: fv!item.name
          ),
          a!textField(
            value: fv!item.value,
            saveInto: fv!item.value
          )
        }
      )
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem of saving updated grid field in database</title><link>https://community.appian.com/thread/78788?ContentTypeID=1</link><pubDate>Thu, 07 Jan 2021 10:03:21 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:676ba1d1-e086-4010-92f0-c6eb42515ba4</guid><dc:creator>dhavalp0001</dc:creator><description>&lt;p&gt;your first approach is good but this value is if one of the field of grid. so it&amp;#39;s in foreach loop. So how can i use local variable where i want each row value in rule input of expression rule.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem of saving updated grid field in database</title><link>https://community.appian.com/thread/78780?ContentTypeID=1</link><pubDate>Wed, 06 Jan 2021 17:54:13 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:260e32b8-3688-4c26-898a-b187213a0a16</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;One important thing to know about SAIL is that the saveInto is only triggered if you interact with the field. So even if the value displays as 5, that value doesn&amp;#39;t get saved upon submit on the form unless you typed something into the field.&lt;/p&gt;
&lt;p&gt;Usually in cases like this, I&amp;#39;d suggest one of two other approaches:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Define the value on load of the page rather than in the value section - this can be done by setting the initial value of the data equal to the value you want either by setting the data in a local variable or passing data into your rule input via a parameter.&lt;/li&gt;
&lt;li&gt;Use the submit button to update the results - you can be confident that the submit button will be interacted with, so this gives you an opportunity to save your default value of &amp;quot;5&amp;quot; in any fields that don&amp;#39;t currently have a value.&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>