<?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>Need to split CDT elements</title><link>https://community.appian.com/discussions/f/data/12595/need-to-split-cdt-elements</link><description>Hello All, 
 I&amp;#39;m creating an application where there is a requirement to update one of the field of a cdt with the same field of another cdt and store the output into third variable. My scenario for the said work is as below 
 Suppose my two cdt&amp;#39;s are</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Need to split CDT elements</title><link>https://community.appian.com/thread/56163?ContentTypeID=1</link><pubDate>Mon, 04 Jun 2018 11:17:22 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9af6442f-d671-468c-9a3b-2021c7b2477b</guid><dc:creator>viveku3486</dc:creator><description>Thanks Josep,&lt;br /&gt;
&lt;br /&gt;
This helped me, This was my exact requirement. Thanks a ton Jose. Also thanks to everyone for putting your efforts and giving your precious times for the resolution of this issue. I think my requirement was not that cleared and that is why we got multiple resolutions but in any case all your posts are helpful may be not in this case but in some other one.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Need to split CDT elements</title><link>https://community.appian.com/thread/56134?ContentTypeID=1</link><pubDate>Sun, 03 Jun 2018 22:42:28 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:7fded295-9d98-472f-928a-2212e12fda75</guid><dc:creator>aloks0189</dc:creator><description>&lt;p&gt;Hi   as per your explanation, what I understood is, finally you are getting an array as the response which has 3 items in it where one of the item is duplicate. Which can be resolved by union() as you already have mention, &lt;/p&gt;
&lt;p&gt;But still I don&amp;#39;t understand the meaning of &amp;quot;first two element is considered as a single item&amp;quot; why first 2 items will be considered as single item?&lt;/p&gt;
&lt;p&gt;Also as I can see, you have a duplicate item so why are you considering this duplicate item? I believe the totalCount should be 2 instead of 3 unless you want to retain the duplicate values as well.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Need to split CDT elements</title><link>https://community.appian.com/thread/56132?ContentTypeID=1</link><pubDate>Sun, 03 Jun 2018 15:34:46 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3cddcf3f-5d21-467e-9641-549accb9d133</guid><dc:creator>harrisont606</dc:creator><description>Why are you trying to store the exact same amount value in two different CDTs? There definitely can be use cases for this type of deonormalization, but it seems to me that if two rows have the same value that this should be stored via a foreign key relationship instead of saving the data twice. This can lead to data corruption in your application if they ever fall out of sync. Once this issue pops up, it can be very painful to resolve.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Need to split CDT elements</title><link>https://community.appian.com/thread/56102?ContentTypeID=1</link><pubDate>Fri, 01 Jun 2018 18:48:01 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:7a5af458-675d-4fee-bf8b-b69feb071d06</guid><dc:creator>PhilB</dc:creator><description>&lt;p&gt;Hopefully this is what you want, or at least will help get you to where you need to be. Note that the extra index(..., 1...) for&amp;nbsp;local!matchesOnClaimIdAndClaimType isn&amp;#39;t required if you have an &amp;quot;is null or empty&amp;quot; rule available to use in the if() towards the end of the rule.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;load(
  local!arrayOfCdt1: {
    {amount:100, claimId: 10, claimType: 1},
    {amount:100, claimId: 10, claimType: 1},
    {amount:200, claimId: 20, claimType: 2},
    {amount:700, claimId: 10, claimType: 2},
  },
  local!arrayOfCdt2: {
    {amount:110, claimId: 11, claimType: 1},
    {amount:110, claimId: 11, claimType: 1},
    {amount:210, claimId: 20, claimType: 1},
    {amount:710, claimId: 20, claimType: 2},
  },
  a!forEach(
    items: local!arrayOfCdt1,
    expression: with(
      local!matchesOnClaimId: index(
        local!arrayOfCdt2,
        wherecontains(
          fv!item.claimId,
          local!arrayOfCdt2.claimId
        ),
        {}
      ),
      local!matchesOnClaimIdAndClaimType: index(
        index(
          local!matchesOnClaimId,
          wherecontains(
            fv!item.claimType,
            local!matchesOnClaimId.claimType
          ),
          null
        ),
        1,
        null
      ),
      if(
        isnull(
          local!matchesOnClaimIdAndClaimType
        ),
        fv!item,
        local!matchesOnClaimIdAndClaimType
      )
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Need to split CDT elements</title><link>https://community.appian.com/thread/56101?ContentTypeID=1</link><pubDate>Fri, 01 Jun 2018 18:05:02 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9b10b65d-2d71-4695-973c-f026c505f53f</guid><dc:creator>josep</dc:creator><description>Hello vivek, &lt;br /&gt;
&lt;br /&gt;
I haven&amp;#39;t reviewed your whole logic(I might have some comments), but from your question, Have you tried flatten function?&lt;br /&gt;
&lt;a href="https://docs.appian.com/suite/help/18.2/fnc_array_a_flatten.html"&gt;docs.appian.com/.../fnc_array_a_flatten.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Jose&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>