<?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>Best way to compare two array of CDT and remove duplicates based on certain fields?</title><link>https://community.appian.com/discussions/f/rules/30493/best-way-to-compare-two-array-of-cdt-and-remove-duplicates-based-on-certain-fields</link><description>I need to compare two lists of the same type of cdt, and remove any duplicates from one of the lists if two of the fields match. For example 
 
 CDT Array 1: 
 { type!example( 
 email: &amp;quot;hello@gmail.com&amp;quot;, 
 type: 1, 
 date: 05/05/2019 
 ) 
 } 
 
 CDT Array</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Best way to compare two array of CDT and remove duplicates based on certain fields?</title><link>https://community.appian.com/thread/121250?ContentTypeID=1</link><pubDate>Wed, 01 Nov 2023 23:19:34 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e1a6f9bb-c001-405d-a0c4-6a1bc4f1306f</guid><dc:creator>walkers</dc:creator><description>&lt;p&gt;That worked, thank you &lt;a href="/members/matthew.shutt"&gt;matthew.shutt&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to compare two array of CDT and remove duplicates based on certain fields?</title><link>https://community.appian.com/thread/121245?ContentTypeID=1</link><pubDate>Wed, 01 Nov 2023 15:13:11 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:06840b71-f774-46b5-9f6c-82d124f3bb22</guid><dc:creator>matthew.shutt</dc:creator><description>&lt;p&gt;Would something like this work?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!one: {
    a!map(
      email: &amp;quot;hello@gmail.com&amp;quot;,
      type: 1,
      date: 05 / 05 / 2019
    )
  },
  local!two: {
    a!map(
      email: &amp;quot;hello@gmail.com&amp;quot;,
      type: 1,
      date: 01 / 01 / 2022
    ),
    a!map(
      email: &amp;quot;hello11@gmail.com&amp;quot;,
      type: 1,
      date: 03 / 02 / 2023
    ),
    a!map(
      email: &amp;quot;hello@gmail.com&amp;quot;,
      type: 2,
      date: 01 / 02 / 2023
    )
  },
  index(
    local!two,
    where(
      a!forEach(
        local!two,
        a!isNullOrEmpty(
          intersection(
            wherecontains(fv!item.email, local!one.email),
            wherecontains(fv!item.type, local!one.type)
          )
        )
      ),
      local!two
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to compare two array of CDT and remove duplicates based on certain fields?</title><link>https://community.appian.com/thread/121244?ContentTypeID=1</link><pubDate>Wed, 01 Nov 2023 14:30:02 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:2b4a0c57-240f-4f6c-8165-da59d6667bb0</guid><dc:creator>walkers</dc:creator><description>&lt;p&gt;Hi Bmsv, I don&amp;#39;t think this will work because I only want to compare a few fields from each array of CDTS, not all the fields.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to compare two array of CDT and remove duplicates based on certain fields?</title><link>https://community.appian.com/thread/121197?ContentTypeID=1</link><pubDate>Wed, 01 Nov 2023 06:10:43 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6cd601f6-da8e-434d-ad48-bb81ba7d2fec</guid><dc:creator>Bmsv</dc:creator><description>&lt;p&gt;You can use difference() function. In your case it will be difference(Array2,Array1).&lt;/p&gt;
&lt;p&gt;Hope it works&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>