<?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>Save button should get enabled if  changes are made to initial submission</title><link>https://community.appian.com/discussions/f/user-interface/25302/save-button-should-get-enabled-if-changes-are-made-to-initial-submission</link><description>Under the form, I have a save button that will be disabled after the form submission. The button should be enabled if any changes are made to the data or a comment is added.Any help will be appreciated.</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Save button should get enabled if  changes are made to initial submission</title><link>https://community.appian.com/thread/98564?ContentTypeID=1</link><pubDate>Wed, 27 Jul 2022 21:26:57 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:db36fb09-8f2f-4cc6-b132-ac3d6dc9601e</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;I&amp;#39;m a little confused at the context here, but for times where you need to access an index (numeric position) in an array where you&amp;#39;re not 100% sure that index will exist, you should use the index() function with a &amp;quot;default&amp;quot; parameter.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Save button should get enabled if  changes are made to initial submission</title><link>https://community.appian.com/thread/98561?ContentTypeID=1</link><pubDate>Wed, 27 Jul 2022 18:26:57 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:609be25d-7195-495e-898e-83c87dbf144c</guid><dc:creator>Tan18</dc:creator><description>&lt;p&gt;Yes, I checked, it&amp;#39;s not doing the data comparison.so I added the other rule input for original value and used the following code for the interface with multiple child interfaces.It works when I remove indexing for one interface but with fv!index&amp;nbsp; I am getting error stating:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Interface Definition: Expression evaluation error at function a!forEach [line 148]: Error in a!forEach() expression during iteration 1: Expression evaluation error : Invalid index (1) for null value of type SS_Data?list. Any suggestions&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;local!changesMadeToData:a!forEach(
    items: ri!Data,
    expression: fv!item=ri!OrignalData[fv!index]
  ),&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Save button should get enabled if  changes are made to initial submission</title><link>https://community.appian.com/thread/98465?ContentTypeID=1</link><pubDate>Tue, 26 Jul 2022 18:34:49 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1c8797c2-9929-49e9-a779-3a1fb16ef994</guid><dc:creator>Mike Schmitt</dc:creator><description>[quote userid="88894" url="~/discussions/f/user-interface/25302/save-button-should-get-enabled-if-changes-are-made-to-initial-submission/98464#98464"]Whenever I do some changes to data buttons&amp;nbsp;are not getting enabled[/quote]
&lt;p&gt;You should be troubleshooting this by viewing the values of the local variables in the interface designer&amp;#39;s &amp;quot;local variables&amp;quot; pane as you enter new values for test inputs, etc.&amp;nbsp; For instance you should be able to see the value of &amp;quot;local!modified&amp;quot; change, not just judging by whether or not the buttons become enabled.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As always, I suggest you start with simpler code that you can understand, and work up from there only once you absolutely understand what&amp;#39;s going on.&amp;nbsp; If it helps, see the simplified example code I posted above, which can be copied/pasted into a blank interface designer window and tested with.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Save button should get enabled if  changes are made to initial submission</title><link>https://community.appian.com/thread/98464?ContentTypeID=1</link><pubDate>Tue, 26 Jul 2022 18:26:33 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:7987c5a1-c2a4-4279-95c6-c7008b62d29d</guid><dc:creator>Tan18</dc:creator><description>&lt;p&gt;These mistakes happened as I updated my initial code in this thread but in designer, it&amp;#39;s correctly spelled. But somehow I feel this logic is not working . Whenever I do some changes to data buttons&amp;nbsp;are not getting enabled. Adding is modified rule input to all nested interfaces will be hard. it will break the correct working from&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Save button should get enabled if  changes are made to initial submission</title><link>https://community.appian.com/thread/98463?ContentTypeID=1</link><pubDate>Tue, 26 Jul 2022 18:25:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1057a261-3e73-45b0-899f-5130702d8207</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Here&amp;#39;s a simplified, ready-to-paste example of exactly how this sort of thing can-and-should work, FWIW.&lt;br /&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!localVariables(
  local!name: &amp;quot;Mike&amp;quot;,
  local!date: today()-4,
  
  local!data: {
    local!name,
    local!date
    /*ri!datasubset,
    ri!transValue,
    ri!orgValue,
    ri!ageValue*/
  },
  local!originalData: a!refreshVariable(
    value: local!data,
    refreshOnReferencedVarChange: false()
  ),
  local!modified: not(
    exact(
      tostring(local!data),
      tostring(local!originalData)
    )
  ),

  a!formLayout(
    contents: {
      a!textField(
        label: &amp;quot;Name&amp;quot;,
        value: local!name,
        saveInto: local!name
      ),
      a!dateField(
        label: &amp;quot;Date&amp;quot;,
        value: local!date,
        saveInto: local!date
      ),
      a!richTextDisplayField(
        value: {
          a!richTextItem(
            text: &amp;quot;not modified...&amp;quot;,
            showWhen: not(local!modified),
            style: &amp;quot;EMPHASIS&amp;quot;,
            color: &amp;quot;SECONDARY&amp;quot;
          ),
          a!richTextItem(
            showWhen: local!modified,
            text: &amp;quot;Modified!&amp;quot;,
            color: &amp;quot;POSITIVE&amp;quot;,
            style: &amp;quot;STRONG&amp;quot;
          )
        }
      )
    }
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;img height="156" src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/13/pastedimage1658859959318v1.png" width="287" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img height="173" src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/13/pastedimage1658859977831v2.png" width="235" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Save button should get enabled if  changes are made to initial submission</title><link>https://community.appian.com/thread/98462?ContentTypeID=1</link><pubDate>Tue, 26 Jul 2022 18:19:52 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:22119ba9-0dfe-4200-9802-455fbe9c42c3</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Also, this is not the correct name&lt;br /&gt;&lt;img alt=" " src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/13/pastedimage1658859586839v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;The actual function name is &amp;quot;a!refreshVariable()&amp;quot;&lt;br /&gt;&lt;img alt=" " src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/13/pastedimage1658859624539v2.png" /&gt;&lt;/p&gt;
&lt;p&gt;Additionally the correct spelling of the parameter name is &amp;quot;refreshOnReference&lt;strong&gt;d&lt;/strong&gt;VarChange&amp;quot; - not &amp;quot;refreshOnReferenceVarChange&amp;quot;.&amp;nbsp; The interface designer&amp;#39;s built-in error messages should prompt you for these things.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Save button should get enabled if  changes are made to initial submission</title><link>https://community.appian.com/thread/98461?ContentTypeID=1</link><pubDate>Tue, 26 Jul 2022 18:16:53 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8d4ce9f2-c1fe-4729-92fe-076a80bf3fb3</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;I&amp;#39;m confused though, because the updated code you&amp;#39;ve attached here doesn&amp;#39;t seem to have any places where local!data and/or any of the 4 RI variables it references, get modified whatsoever.&amp;nbsp; So how are you actually performing changes to the underlying data to verify that local!modified isn&amp;#39;t working correctly?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Save button should get enabled if  changes are made to initial submission</title><link>https://community.appian.com/thread/98460?ContentTypeID=1</link><pubDate>Tue, 26 Jul 2022 18:04:54 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1ecc2e0a-ab39-435d-9375-d7a7cac46ba9</guid><dc:creator>Tan18</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!data: {
    
       
        ri!datasubset,
        ri!transValue,
        ri!orgValue,
        ri!ageValue
      
    
  },
  local!originalData:a!refreshVariables(
  value:local!data,
  refreshOnReferenceVarChange:false()
  ),
    local!modified: not(
      exact(
        tostring(local!data),
        tostring(local!originalData)
      )
    ),

    a!formLayout(
      buttons: a!buttonLayout(
        primaryButtons: 
        if(
          ri!isEditable,
          {
            if(
              ri!canSubmit,
              a!buttonWidget(
                label: cons!BUTTON_VAL_SUBMIT,
                style: &amp;quot;PRIMARY&amp;quot;,
                submit: true(),
                validate: true(),
                value: cons!BUTTON_VAL_SUBMIT,
                saveInto: ri!buttonAction,
                disabled: 
                if(

                  and(rule!APN_hasValue ( ri!SubmissionDate),local!originalData&amp;lt;&amp;gt;local!modified),
                 false(),
                 true(),
                )

              ),
              {}
            ),
            a!buttonWidgetSubmit(
              label: cons!BUTTON_VAL_SAVE,
              style: if(
                ri!canSubmit,
                &amp;quot;NORMAL&amp;quot;,
                &amp;quot;PRIMARY&amp;quot;
              ),
              submit: true(),
              validate: true(),
              value: cons!BUTTON_VAL_SAVE,
              saveInto: ri!buttonAction,
              disabled: 
              if(

                and(rule!APN_hasValue ( ri!SubmissionDate),not(local!modified),
                false(),
                true(),
              )
            )
          },
          {}
        )
      )
      )
    
  )&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Save button should get enabled if  changes are made to initial submission</title><link>https://community.appian.com/thread/98459?ContentTypeID=1</link><pubDate>Tue, 26 Jul 2022 17:59:06 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:45bcd49a-55e9-4d6d-9187-068116d6c84f</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Where and how are you saving the updates to the &amp;quot;local!data&amp;quot; variable (and/or its refernced variables)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Save button should get enabled if  changes are made to initial submission</title><link>https://community.appian.com/thread/98458?ContentTypeID=1</link><pubDate>Tue, 26 Jul 2022 17:57:11 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:91800ff3-994a-4559-9a61-1b970e23c7b6</guid><dc:creator>Tan18</dc:creator><description>&lt;p&gt;I tried this way and it seems it&amp;#39;s not performing data comparison. Is there any other possible way, it can perform a logical comparison and gets enables button with the changes&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Save button should get enabled if  changes are made to initial submission</title><link>https://community.appian.com/thread/98450?ContentTypeID=1</link><pubDate>Tue, 26 Jul 2022 15:51:28 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c29269b2-3555-43d7-af17-bacec1fa832e</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;This would work except the way you&amp;#39;ve declared &lt;em&gt;&lt;strong&gt;local!originalData&lt;/strong&gt;&lt;/em&gt;, is causing it to automatically update any time any change is made to local!data.&lt;/p&gt;
&lt;p&gt;Remember that &lt;em&gt;a!localVariables()&lt;/em&gt; variables have a &lt;strong&gt;default behavior&lt;/strong&gt; which assumes &amp;quot;refresh on referenced var change&amp;quot; is TRUE.&amp;nbsp; That means, as you have it written, if you save anything into ri!orgValue (for instance), it automatically refreshes local!data, which by update chaining, updates local!originalData (which you don&amp;#39;t want).&lt;/p&gt;
&lt;p&gt;Luckily the fix is very simple.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;  local!originalData: a!refreshVariable(
    value: local!data,
    refreshOnReferencedVarChange: false()
  )&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;With the above change in place, your &amp;quot;local!modified&amp;quot; variable should now properly hold its existing value in spite of updates made to the referenced variable.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Save button should get enabled if  changes are made to initial submission</title><link>https://community.appian.com/thread/98449?ContentTypeID=1</link><pubDate>Tue, 26 Jul 2022 15:46:25 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b2c1e393-9b38-492b-a378-3aaf02f29d27</guid><dc:creator>Tan18</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!data: {
    
       
        ri!datasubset,
        ri!transValue,
        ri!orgValue,
        ri!ageValue
      
    
  },
  local!originalData:local!data,
  
    local!modified: not(
      exact(
        tostring(local!data),
        tostring(local!originalData)
      )
    ),

    a!formLayout(
      buttons: a!buttonLayout(
        primaryButtons: 
        if(
          ri!isEditable,
          {
            if(
              ri!canSubmit,
              a!buttonWidget(
                label: cons!BUTTON_VAL_SUBMIT,
                style: &amp;quot;PRIMARY&amp;quot;,
                submit: true(),
                validate: true(),
                value: cons!BUTTON_VAL_SUBMIT,
                saveInto: ri!buttonAction,
                disabled: 
                if(

                  and(rule!APN_hasValue ( ri!SubmissionDate),local!originalData&amp;lt;&amp;gt;local!modified),
                 false(),
                 true(),
                )

              ),
              {}
            ),
            a!buttonWidgetSubmit(
              label: cons!BUTTON_VAL_SAVE,
              style: if(
                ri!canSubmit,
                &amp;quot;NORMAL&amp;quot;,
                &amp;quot;PRIMARY&amp;quot;
              ),
              submit: true(),
              validate: true(),
              value: cons!BUTTON_VAL_SAVE,
              saveInto: ri!buttonAction,
              disabled: 
              if(

                and(rule!APN_hasValue ( ri!SubmissionDate),local!originalData&amp;lt;&amp;gt;local!modified),
                false(),
                true(),
              )
            )
          },
          {}
        )
      )
      )
    
  )
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I tried this code for the interface with multiple child interfaces. buts it&amp;#39;s not working.even if data is changed , the buttons are not getting enabled. Any suggestions?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Save button should get enabled if  changes are made to initial submission</title><link>https://community.appian.com/thread/98370?ContentTypeID=1</link><pubDate>Mon, 25 Jul 2022 19:17:54 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ad2427bb-f72a-4cce-8e7f-99ad1cc7f21e</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;for any child interfaces where data could also be modified, and which would thus need to trip the &amp;quot;isModified&amp;quot; flag, simply pass in the &amp;quot;isModified&amp;quot; local variable into a rule input in the child(ren), and save into it from any relevant field(s) there.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Save button should get enabled if  changes are made to initial submission</title><link>https://community.appian.com/thread/98368?ContentTypeID=1</link><pubDate>Mon, 25 Jul 2022 18:37:28 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a949ec9d-39de-4f62-a789-8ecaf521bfda</guid><dc:creator>Tan18</dc:creator><description>&lt;p&gt;if there are nested interfaces, where the above example for data comparison cant be used?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Save button should get enabled if  changes are made to initial submission</title><link>https://community.appian.com/thread/98352?ContentTypeID=1</link><pubDate>Mon, 25 Jul 2022 15:07:14 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c813bef8-9123-414a-a815-7cc01682be6a</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;A simplified example:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!textField(
  label: &amp;quot;my data&amp;quot;,
  value: ri!textField1Value,
  saveInto: {
    ri!textField1Value,
    a!save(
      local!isModified,
      true()
    )
  }
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Save button should get enabled if  changes are made to initial submission</title><link>https://community.appian.com/thread/98343?ContentTypeID=1</link><pubDate>Mon, 25 Jul 2022 14:35:31 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:cd4f8152-11ae-44fb-bd6b-f09f0540aa4e</guid><dc:creator>Tan18</dc:creator><description>&lt;p&gt;do u have any example to quote?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Save button should get enabled if  changes are made to initial submission</title><link>https://community.appian.com/thread/98340?ContentTypeID=1</link><pubDate>Mon, 25 Jul 2022 14:06:26 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c422ea11-a685-4c8e-82c1-e61910488623</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;For what it&amp;#39;s worth, this could have just been a new comment in your &lt;a href="/discussions/f/user-interface/25247/disable-save-and-submit-button"&gt;existing thread&lt;/a&gt; on the same subject.&amp;nbsp; The problem with arbitrarily staring brand new threads is that people seeing it for the first time won&amp;#39;t be able to review the past comments and any context they may provide.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Save button should get enabled if  changes are made to initial submission</title><link>https://community.appian.com/thread/98337?ContentTypeID=1</link><pubDate>Mon, 25 Jul 2022 13:33:41 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:69c19817-f4ea-46fe-8cbc-9426742192db</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;I recommend to not implement one huge form covering all use cases. This becomes complex and hard to maintain.&lt;/p&gt;
&lt;p&gt;But, to answer your question, add a local variable &amp;quot;isModified&amp;quot; and default it to false. Then add a a!save()&amp;nbsp;to all fields to update isModified to true(). Then use that status to add some logic to the submit button.&lt;/p&gt;
&lt;p&gt;Now, check my first sentence ...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>