<?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>How to compare whether two objects are the same</title><link>https://community.appian.com/discussions/f/rules/39346/how-to-compare-whether-two-objects-are-the-same</link><description>I have a structure of record type A like this: 
 {id: 
 other business field:, 
 relationships: 
 record Type2: { 
 id, 
 A_id, 
 other business field 
 } 
 recordType3: 
 { 
 id, 
 A_id, 
 other business field 
 } 
 }, 
 
 After user change the data</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to compare whether two objects are the same</title><link>https://community.appian.com/thread/149351?ContentTypeID=1</link><pubDate>Thu, 26 Jun 2025 12:37:22 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:0c94b731-b26b-4e28-b6af-f792041d48c4</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;I&amp;#39;d like to note an important corner case here - if the user swaps two values between rows but otherwise makes no changes, such as changing the Unit Price of row 1 to 20, and for row 2 to 10 - the Symmetric Differences will all still turn up the same, and the form will thus (incorrectly) assume changes have not been made.&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/15/pastedimage1750941707468v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;Edit: to solve this, you could take a similar approach but instead of comparing merely the original arrays in a manner that ignores positional context of individual data items, you could easily assemble easy-to-compare arrays of text items, where each text item in the array holds all the data we care about.&amp;nbsp; Then when any update is made, including an identical swap of data between rows, it&amp;#39;s reflected in the symmetricDifference() result:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/15/pastedimage1750942492360v1.png" alt=" " /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/15/pastedimage1750942535699v2.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to compare whether two objects are the same</title><link>https://community.appian.com/thread/149323?ContentTypeID=1</link><pubDate>Thu, 26 Jun 2025 00:26:55 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1fba34bf-5597-42d8-a566-c0bceebdb0a9</guid><dc:creator>Peon</dc:creator><description>&lt;p&gt;because the original data has ID field, if user remove the original data and add a same data, the id field is different, symmetricdifference() thinks they are different, But what I want is they&amp;nbsp;should be same.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to compare whether two objects are the same</title><link>https://community.appian.com/thread/149307?ContentTypeID=1</link><pubDate>Wed, 25 Jun 2025 13:29:23 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:64429b2d-4486-4708-9c4d-2a8fef79de7b</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;This is a little hacky, but I have eventually settled on doing something like this:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;span style="color:#0000ff;"&gt;local!areChangesMade&lt;/span&gt;: not( exact( tostring(&lt;span style="color:#008000;"&gt;local!originalSavedValue&lt;/span&gt;), tostring(&lt;span style="color:#ff6600;"&gt;local!userEditableValue&lt;/span&gt;) ) ),&lt;/em&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;/* evaluates to true or false, catches changes as small as changed capitalization */&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to compare whether two objects are the same</title><link>https://community.appian.com/thread/149302?ContentTypeID=1</link><pubDate>Wed, 25 Jun 2025 11:56:54 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8224f4b1-1d60-4919-b9ac-081a96a43f84</guid><dc:creator>Shubham Aware</dc:creator><description>&lt;p&gt;&lt;span&gt;I&amp;#39;m having a hard time understanding this. Since you only need to find out whether the business field has been modified or not (true/false), you can directly use symmetricDifference() for this. Why are you traversing and constructing a new object?&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;length(
  symmetricdifference(
    local!originalArray,
    local!updatedArray
  )
) &amp;lt;&amp;gt; 0&lt;/pre&gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to compare whether two objects are the same</title><link>https://community.appian.com/thread/149301?ContentTypeID=1</link><pubDate>Wed, 25 Jun 2025 11:55:49 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:cd7dcafc-6689-400a-ab9d-01f39d896f49</guid><dc:creator>Harsha Sharma</dc:creator><description>&lt;p&gt;Instead of creating new objects you can simply compare the business fields for similarity and depending on output disable/enable the submit button.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Keep the data before any changes are made in a variable and keep one variable to do comparison of old data with variable having changes due to user interaction. The output of this variable can build the logic to manage the submit button. Below is an example for reference,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!oldItems: {
    {id:1,item: &amp;quot;Item 1&amp;quot;, qty: 1, unitPrice: 10,user:&amp;quot;JAdoe&amp;quot;},
    {id:2,item: &amp;quot;Item 2&amp;quot;, qty: 2, unitPrice: 20,user:&amp;quot;AHer&amp;quot;}
  },
  local!newItems: {
    {id:1,item: &amp;quot;Item 1&amp;quot;, qty: 1, unitPrice: 10,user:&amp;quot;JAdoe&amp;quot;},
    {id:null,item: &amp;quot;Item 2&amp;quot;, qty: 2, unitPrice: 20,user:&amp;quot;PTer&amp;quot;}
  },
  /*If true, disable button*/
  and(a!isNullOrEmpty(symmetricdifference(local!oldItems.item,local!newItems.item)),
  a!isNullOrEmpty(symmetricdifference(local!oldItems.qty,local!newItems.qty)),
  a!isNullOrEmpty(symmetricdifference(local!oldItems.unitPrice,local!newItems.unitPrice)))
)
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to compare whether two objects are the same</title><link>https://community.appian.com/thread/149298?ContentTypeID=1</link><pubDate>Wed, 25 Jun 2025 11:32:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:44472037-1590-4cd8-8141-a36f8d14a78e</guid><dc:creator>Peon</dc:creator><description>&lt;p&gt;both the original data and new data are list, I want to use&amp;nbsp;symmetricdifference() to compare the original data and the new data, so I try to reconstruct the objects,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to compare whether two objects are the same</title><link>https://community.appian.com/thread/149297?ContentTypeID=1</link><pubDate>Wed, 25 Jun 2025 11:24:15 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:684b8171-08b1-496f-8286-5e3a59f00b06</guid><dc:creator>Shubham Aware</dc:creator><description>&lt;p&gt;&lt;span data-teams="true"&gt;For detecting business field changes in your record, store the original record when the form loads, then use direct field comparison. Simply compare original.otherBusinessField &amp;lt;&amp;gt; current.otherBusinessField for each business field you care about. This is much more efficient than traversing and reconstructing objects. You can wrap this in a reusable rule that returns true/false for whether any business fields changed.&lt;br /&gt; For real-time tracking, add change flags in your saveInto parameters. Avoid object reconstruction - direct comparison is faster, simpler, and more maintainable.&lt;br /&gt;Give it a try..&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to compare whether two objects are the same</title><link>https://community.appian.com/thread/149296?ContentTypeID=1</link><pubDate>Wed, 25 Jun 2025 11:17:04 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e6f355bc-9649-4538-b6e2-4fb613d6c4d9</guid><dc:creator>Peon</dc:creator><description>&lt;p&gt;yes, the requirement is just a CRUD for a table. But user&amp;#39;s behavior may be like this, remove a row, and add a new row, but the new row&amp;#39;s data same as the deleted one. the reason I want to compare the data is if the user&amp;#39;s behavior like I mentioned, I will make the submit button disable, not allow user to submit.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to compare whether two objects are the same</title><link>https://community.appian.com/thread/149295?ContentTypeID=1</link><pubDate>Wed, 25 Jun 2025 11:12:39 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c504f887-a449-425a-a21f-71b560ba2888</guid><dc:creator>Peon</dc:creator><description>&lt;p&gt;yes that what I want to say.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to compare whether two objects are the same</title><link>https://community.appian.com/thread/149294?ContentTypeID=1</link><pubDate>Wed, 25 Jun 2025 11:11:58 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:828b1902-2fcc-4c41-a327-e6b4a23080c4</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;I think this is a good way of doing it. In the end, the meaning of &amp;quot;record has changed&amp;quot; very much depends on business requirements. Not every field in a record is affected.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to compare whether two objects are the same</title><link>https://community.appian.com/thread/149293?ContentTypeID=1</link><pubDate>Wed, 25 Jun 2025 11:06:23 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b7caa0af-f0b2-48a7-a433-072959d72c59</guid><dc:creator>Guduri Durga Pavan SriHari Raju</dc:creator><description>&lt;p&gt;&amp;nbsp;&lt;a href="/members/edwardc8281"&gt;Peon&lt;/a&gt;&amp;nbsp;&lt;span&gt;What I understand is that you want to verify if the business field has been changed. Before saving the data into the table, you are comparing the old field value with the newly added values from Appian. Is that correct?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>