<?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 find different property of two objects.</title><link>https://community.appian.com/discussions/f/data/39921/how-to-find-different-property-of-two-objects</link><description>I have two objects they all the same type. I want to compare the two objects and extract which properties are different. Besides using a loop to iterate, is there a better way?</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to find different property of two objects.</title><link>https://community.appian.com/thread/152439?ContentTypeID=1</link><pubDate>Fri, 14 Nov 2025 08:01:47 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d512d172-a4df-4e1c-9f6d-a47f3a210c52</guid><dc:creator>Peon</dc:creator><description>&lt;p&gt;Thanks, I want to create a common utils like this.&amp;nbsp;&lt;span class="HwtZe" lang="en"&gt;&lt;span class="jCAhz ChMk0b"&gt;&lt;span class="ryNqvb"&gt;However, it seems a bit difficult at the moment. Besides the problem you mentioned, I also find it hard to determine whether an object is a nested object.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="ZSCsVd"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div class="OvtS8d"&gt;&lt;/div&gt;
&lt;div class="NQSJo"&gt;&lt;/div&gt;
&lt;div class="UdTY9 WdefRb" data-location="2"&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to find different property of two objects.</title><link>https://community.appian.com/thread/152438?ContentTypeID=1</link><pubDate>Fri, 14 Nov 2025 07:55:29 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4cb8dbdc-5ecb-4227-b9fb-afbe78e09943</guid><dc:creator>Shubham Aware</dc:creator><description>&lt;p&gt;Doesn&amp;#39;t support recursive function calls(&lt;span&gt;you can simulate it by having an expression rule call itself conditionally to compare nested maps, checking property types and combining differences from each level&lt;/span&gt;)&lt;br /&gt;For nested structures:&lt;br /&gt;Compare each level separately (manual nesting)&lt;br /&gt;Flatten structure first, then compare&lt;br /&gt;JSON comparison -&amp;gt; a!toJson(obj1) = a!toJson(obj2) (only tells If different, not what)&lt;/p&gt;
&lt;p&gt;Best approach as per my understanding, Handle each nesting level explicitly with separate comparison logic.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to find different property of two objects.</title><link>https://community.appian.com/thread/152437?ContentTypeID=1</link><pubDate>Fri, 14 Nov 2025 07:33:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:92ab1e4e-08e4-4613-88d7-d76507ba9777</guid><dc:creator>Peon</dc:creator><description>&lt;p&gt;Ok I got it, but&amp;nbsp;what&lt;span&gt;&amp;nbsp;if my data structure is a nested structure? like this.&amp;nbsp;Can I call this method recursively like in Java?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt; local!employee1: {
    name: &amp;quot;John&amp;quot;,
    age: 30,
    dept: {
        name: &amp;quot;IT&amp;quot;,
        field2: xx,
        field3: xx
    },
    salary: 50000
  }&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&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 find different property of two objects.</title><link>https://community.appian.com/thread/152411?ContentTypeID=1</link><pubDate>Wed, 12 Nov 2025 14:54:57 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:feb117f5-3e73-423c-9d62-2d369679f7bc</guid><dc:creator>Jesse Knight</dc:creator><description>&lt;p&gt;This one is interesting in how it avoids issues with invalid type comparisons by casting everything to text via the filter predicate rule. I&amp;#39;ll have to keep it in mind for the future as it makes things much more resilient in most use cases. What&amp;#39;s fun - I think there&amp;#39;s a way to change the &lt;code&gt;a!forEach()&lt;/code&gt; into a &lt;code&gt;fn!reduce&lt;/code&gt;, to remove the &amp;quot;loop&amp;quot;, but in reality that just masks the loop within a looping function.&lt;/p&gt;
&lt;p&gt;The only caution with this approach for a generic rule is when dealing with numbers that have leading or trailing zeros - for example, 0.20 should be considered equal to 0.2 in many finance contexts.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to find different property of two objects.</title><link>https://community.appian.com/thread/152399?ContentTypeID=1</link><pubDate>Wed, 12 Nov 2025 08:12:21 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8a1f3152-6ea4-4df3-b487-19387c04b81f</guid><dc:creator>Harsha Sharma</dc:creator><description>&lt;p&gt;If you want just to check whether the variables/datasets&amp;nbsp;are different or not then convert the datasets into json using a!toJson() and then compare like&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;a!tojson(a!map(key: 2, value: 2)) = a!tojson(a!map(key: 1, value: 2))&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If you want a list of attributes and values which vary between two datasets then a!foreach() is needed atleast once to parse and check each field in the datatype.&lt;/p&gt;
&lt;p&gt;Below is a solution with two expressions which can help with this part. In one expression we just have simple expression to compare 2 values which returns true if values dont match.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/16/pastedimage1762935010905v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;In main expression we have code like below which filters and returns the field and values where match failed.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!map1: { name: &amp;quot;Alex&amp;quot;, age: &amp;quot;22&amp;quot;, dob: today() },
  local!map2: { name: &amp;quot;Alexa&amp;quot;, age: &amp;quot;22&amp;quot;, dob: today() - 4 },
  local!keys: a!keys(local!map1),
  a!foreach(
    local!keys,
    a!map(
      field: fv!item,
      value: filter(
        rule!HSS_CompareValues,
        merge(
          { index(local!map1, fv!item, {}) },
          { index(local!map2, fv!item, {}) },
          
        )
      )
    )
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;As this uses just one foreach() which iterates for each field in a datatype it will be run for fixed times always and wont affect the performance adversely. Hope this helps!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to find different property of two objects.</title><link>https://community.appian.com/thread/152391?ContentTypeID=1</link><pubDate>Wed, 12 Nov 2025 05:01:41 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:07ccce9a-69cd-464b-9aac-478b50a8fdbc</guid><dc:creator>Shubham Aware</dc:creator><description>&lt;p&gt;Without Loop is not possible.&lt;br /&gt;No built-in way to dynamically index multiple properties without iteration.&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!employee1: {
    name: &amp;quot;John&amp;quot;,
    age: 30,
    dept: &amp;quot;IT&amp;quot;,
    salary: 50000
  },
  local!employee2: {
    name: &amp;quot;John&amp;quot;,
    age: 35,
    dept: &amp;quot;IT&amp;quot;, 
    salary: 55000
  },

  /* Get all property names */
  local!allKeys: a!keys(local!employee1),

  /* Check which properties are different */
  local!areEqual: a!forEach(
    local!allKeys,
    index(local!employee1, fv!item) = index(local!employee2, fv!item)
  ),

  /* Find properties with different values */
  local!differentProps: index(
    local!allKeys,
    wherecontains(false, local!areEqual),
    null
  ),

  /* Show results */
  {
    differentProperties: local!differentProps,

    oldValues: a!forEach(
      local!differentProps,
      index(local!employee1, fv!item, null)
    ),
    /* Output: {30, 50000} */

    newValues: a!forEach(
      local!differentProps,
      index(local!employee2, fv!item, null)
    )
    /* Output: {35, 55000} */
  }
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>