<?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>Comparing two arrays</title><link>https://community.appian.com/discussions/f/general/17293/comparing-two-arrays</link><description>Hi, 
 
 I have a requirement of displaying an Audit Trail comparing two arrays; Original and updated as follows: 
 
 Original Array: 
 
 [Id=15, PS_Username=VGAN, PS_Fullname=Veron Ganguly], [Id=18, PS_Username=CZUCKERT, PS_Fullname=Curt Zuckert], [Id</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Comparing two arrays</title><link>https://community.appian.com/thread/68210?ContentTypeID=1</link><pubDate>Wed, 17 Jul 2019 07:52:02 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:16e9389d-6e99-4393-9a0c-b5736e40c230</guid><dc:creator>ankitab0001</dc:creator><description>&lt;p&gt;&lt;a href="/members/apoorvam0001"&gt;apoorvam&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You need to dynamically get the list of the cdt fields and compare the value of each field.&lt;/p&gt;
&lt;p&gt;I have written a sample code. This might help. You can improvise this to make it more efficient.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
load(
  local!originalCdt: &amp;#39;type!{http://www.telstra.com.au/PDSA/}PD_PAYMENT_CLAIM&amp;#39;(  
  ),
  local!cdtFileds:split(cast(103,local!originalCdt),&amp;quot;=&amp;quot;),
  local!cleanedFields:stripwith(stripwith(stripwith(local!cdtFileds,&amp;quot;]&amp;quot;),&amp;quot;[&amp;quot;),&amp;quot;, &amp;quot;), /*Clean the fields using regex or other efficient functions*/
  
  local!changedArray: symmetricdifference(ri!updatedCdt,ri!originalCdt),
  
  local!originalArrayChanged:index(ri!originalCdt, wherecontains(local!changedArray,ri!originalCdt),{}),
  local!updatedArrayChanged: difference(ri!updatedCdt,ri!originalCdt),
  
  
  
 a!forEach(
   local!cleanedFields,
   if(contains(index(local!updatedArrayChanged,fv!item,{}),index(local!originalArrayChanged,fv!item,{})),
     {},
     {
       field:fv!item,
       originalValue: index(local!originalArrayChanged,fv!item,{}),
       updatedValue: index(local!updatedArrayChanged,fv!item,{})
     }
   )
 )
  
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Comparing two arrays</title><link>https://community.appian.com/thread/68192?ContentTypeID=1</link><pubDate>Tue, 16 Jul 2019 12:05:12 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:64d47d2d-9450-4378-a617-6623e8e5db1c</guid><dc:creator>Krishna Chaitanya Mallavarapu</dc:creator><description>&lt;p&gt;&lt;span&gt;This may help..&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;load(
  local!originalArray: {
    {
      Id: 15,
      PS_Username: &amp;quot;VGAN&amp;quot;,
      PS_Fullname: &amp;quot;Veron Ganguly&amp;quot;
    },
    {
      Id: 18,
      PS_Username: &amp;quot;CZUCKERT&amp;quot;,
      PS_Fullname: &amp;quot;Curt Zuckert&amp;quot;
    },
    {
      Id: 28,
      PS_Username: &amp;quot;KDUENNHA&amp;quot;,
      PS_Fullname: &amp;quot;Karen Duennhaupt&amp;quot;
    },
    {
      Id: 31,
      PS_Username: &amp;quot;LSWENSON&amp;quot;,
      PS_Fullname: &amp;quot;Liz Swenson&amp;quot;
    },
    {
      Id: 38,
      PS_Username: &amp;quot;POTENKHI&amp;quot;,
      PS_Fullname: &amp;quot;Tatiana Potekhina&amp;quot;
    },
    {
      Id: 40,
      PS_Username: &amp;quot;TCHAN&amp;quot;,
      PS_Fullname: &amp;quot;Tiffany Chan&amp;quot;
    },
    {
      Id: 41,
      PS_Username: &amp;quot;TSTAPLES&amp;quot;,
      PS_Fullname: &amp;quot;Tina Staples&amp;quot;
    },
    {
      Id: 95,
      PS_Username: &amp;quot;MONGEL&amp;quot;,
      PS_Fullname: &amp;quot;Geller&amp;quot;
    },
    {
      Id: 96,
      PS_Username: &amp;quot;CBI&amp;quot;,
      PS_Fullname: &amp;quot;Chand&amp;quot;
    }
  },
  local!updatedArray: {
    {
      Id: 96,
      PS_Username: &amp;quot;CBI&amp;quot;,
      PS_Fullname: &amp;quot;Chandler Bing&amp;quot;
    }
  },
  a!forEach(
    items: local!updatedArray,
    expression: if(
      displayvalue(
        fv!item.Id,
        local!originalArray.Id,
        local!originalArray.PS_Fullname,
        null
      ) = fv!item.PS_Fullname,
      {},
      {
        field: &amp;quot;PS_Fullname&amp;quot;,
        oldValue: displayvalue(
          fv!item.Id,
          local!originalArray.Id,
          local!originalArray.PS_Fullname,
          null
        ),
        newValue: fv!item.PS_Fullname
      }
    )
  )
)&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Comparing two arrays</title><link>https://community.appian.com/thread/68174?ContentTypeID=1</link><pubDate>Mon, 15 Jul 2019 15:07:03 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:af212e38-acf4-4a4b-bb79-a6d7858ddd1a</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;The way I&amp;#39;d implement this would vary depending on particular requirement details that you haven&amp;#39;t provided yet as far as I can see.&amp;nbsp; Just two remaining questions I have, for example:&lt;/p&gt;
&lt;p&gt;1) Will the &amp;quot;updated array&amp;quot; being compared really just be one item from the original array, was that just for illustration purposes and the real comparison would be against the full updated array of CDTs?&lt;/p&gt;
&lt;p&gt;2) Will the comparison always assume that one array member is updated or will it need to handle multiple updated members?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Comparing two arrays</title><link>https://community.appian.com/thread/68169?ContentTypeID=1</link><pubDate>Mon, 15 Jul 2019 12:13:04 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ef81fd93-4f75-4e5f-a133-1cd36df46d34</guid><dc:creator>gayathris</dc:creator><description>&lt;p&gt;&lt;a href="/discussions/f/general/8568/compare-data-changes-in-cdt/37786#37786"&gt;https://community.appian.com/discussions/f/general/8568/compare-data-changes-in-cdt/37786#37786&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This discussion seems relevant. Might be helpful!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>