<?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 update 2 CDT&amp;#39;s with each other values in a process model</title><link>https://community.appian.com/discussions/f/process/23927/how-to-update-2-cdt-s-with-each-other-values-in-a-process-model</link><description>I am new to Appian. Still learning the basics. 
 I have two tables 
 1. Attachments - for adding attachment relate details like fileId,fileName, fileExt, fileSize etc and 
 2. AttachmentDetails - for description, comments etc 
 Below is the requirement</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to update 2 CDT's with each other values in a process model</title><link>https://community.appian.com/thread/92132?ContentTypeID=1</link><pubDate>Fri, 11 Mar 2022 13:36:20 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6f1a9b87-5377-4d86-b797-a49c747809a7</guid><dc:creator>kaushikr0003</dc:creator><description>&lt;p&gt;Thanks&amp;nbsp;&lt;a class="internal-link view-user-profile" href="/members/viraty"&gt;viraty&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;this worked for me.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to update 2 CDT's with each other values in a process model</title><link>https://community.appian.com/thread/92130?ContentTypeID=1</link><pubDate>Fri, 11 Mar 2022 13:35:52 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:599dce0a-219c-43c5-a817-fa3f539c8e82</guid><dc:creator>kaushikr0003</dc:creator><description>&lt;p&gt;Thanks&amp;nbsp;&lt;a class="internal-link view-user-profile" href="/members/andrewh0007"&gt;ajhick&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;for the answer. It was designed initially by senior tech leads that attachment table will be a common table for all the projects and attachmentDetails table is specific for my particular project where they want to store additional information for the attachments they are uploading. So unfortunatly I have to save the details as mentioned above.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to update 2 CDT's with each other values in a process model</title><link>https://community.appian.com/thread/92129?ContentTypeID=1</link><pubDate>Fri, 11 Mar 2022 13:30:16 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e53bb733-91af-42bb-bdb3-33729bbdc0ee</guid><dc:creator>kaushikr0003</dc:creator><description>&lt;p&gt;Thanks&amp;nbsp;&lt;a class="internal-link view-user-profile" href="/members/stefanh0002"&gt;Stefan Helzle&lt;/a&gt;&amp;nbsp;for your reply.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to update 2 CDT's with each other values in a process model</title><link>https://community.appian.com/thread/92102?ContentTypeID=1</link><pubDate>Fri, 11 Mar 2022 04:31:27 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c1fb8d1d-fd1b-411a-b8fa-45966abe894a</guid><dc:creator>viratyogi</dc:creator><description>&lt;p&gt;Hi, if there is one to one relationship I can&amp;#39;t think of any use case where we need to maintain two tables. But in case you want this and there is some use case for the same. Below is&amp;nbsp;one of the possible ways to do it&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  /* Assuming this to be the initial state */
  local!attachment: {
    {
      attachmentId: null,
      fileId: 123,
      attachmentDetailsId: null
    },
    {
      attachmentId: null,
      fileId: 234,
      attachmentDetailsId: null
    }
  },
  local!attachmentDetail: {
    {
      attachmentDetailsId: null,
      Description: &amp;quot;Evidence&amp;quot;,
      attachmentId: null
    },
    {
      attachmentDetailsId: null,
      Description: &amp;quot;Tracker&amp;quot;,
      attachmentId: null
    }
  },
  /* Wrtitng local!attachmentDetail to database using write 
  to datastore entity will give back the Ids for the same */
  local!attachmentDetailAfterWrite: {
    {
      attachmentDetailsId: 1,
      Description: &amp;quot;Evidence&amp;quot;,
      attachmentId: null
    },
    {
      attachmentDetailsId: 1,
      Description: &amp;quot;Tracker&amp;quot;,
      attachmentId: null
    }
  },
  /* We can use below to map the attachment detail in the
attachment table
*/
local!attachmentBeforeWrite:  a!forEach(
    items: local!attachment,
    expression: updatedictionary(
      fv!item,
      {
        attachmentDetailsId: property(
          index(
            local!attachmentDetailAfterWrite,
            fv!index,
            {}
          ),
          &amp;quot;attachmentDetailsId&amp;quot;,
          {}
        )
      }
    )
  )
  
/* You can then write the attachment to database thus generating
the Ids for the same and then use the similar way to map
atatchment Ids to the attachment detail 
*/
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The output of the mapping forloop will be something like this&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;img alt=" " src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/14/5684.output.png" /&gt;&lt;/p&gt;
&lt;p&gt;Hope it helps&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to update 2 CDT's with each other values in a process model</title><link>https://community.appian.com/thread/92055?ContentTypeID=1</link><pubDate>Wed, 09 Mar 2022 22:21:51 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4315ffda-e10b-4a20-a6d2-6d228f1198cc</guid><dc:creator>ajhick</dc:creator><description>&lt;p&gt;Firstly I&amp;#39;d say that you don&amp;#39;t need to reference the other table from BOTH tables. You really only need attachmentId in the Attachment Details table. Also, if it&amp;#39;s a 1 to 1&amp;nbsp;relationship I&amp;#39;m not sure you need the extra table in the first place. This does depend on your exact use case but&amp;nbsp;needing a description for an attachment doesn&amp;#39;t feel like it needs an extra table (especially if a description is mandatory!). Also consider that a document in Appian can have a description too so you might not even need to save this in the database! Again...this does depend on the specific use case.&lt;/p&gt;
&lt;p&gt;I&amp;#39;d suggest considering:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Can you just save the description into the Appian document object?&lt;/li&gt;
&lt;li&gt;Why do you need the extra AttachmentDetails table?&lt;/li&gt;
&lt;li&gt;If you need the extra details table then:
&lt;ol&gt;
&lt;li&gt;You only need to reference the attachmentId from the AttachmentDetails table and not the attachmentDetailsId from the Attachments table&lt;/li&gt;
&lt;li&gt;As Stefan said, you can nest CDTs in each other and if your foreign keys are set up correctly then a write to database node will actually take care of your primary and foreign keys&lt;/li&gt;
&lt;li&gt;You could save to the attachments table first then iterate using a!forEach() save into the attachmentId column of AttachmentDetails. There&amp;#39;s quite a few different ways of doing this depending on the exact set up and it isn&amp;#39;t really preferable.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to update 2 CDT's with each other values in a process model</title><link>https://community.appian.com/thread/92042?ContentTypeID=1</link><pubDate>Wed, 09 Mar 2022 18:48:53 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ea0ca0a5-8f6c-469f-ba82-465883c22721</guid><dc:creator>kaushikr0003</dc:creator><description>&lt;p&gt;I am trying something like this&lt;/p&gt;
&lt;p&gt;a!forEach(&lt;br /&gt; items: ri!attachment,&lt;br /&gt; expression: reduce(&lt;br /&gt; a!update,&lt;br /&gt; fv!item,&lt;br /&gt; merge(&lt;br /&gt; {&amp;quot;attachmentDetailsId&amp;quot;,&amp;quot;folderId&amp;quot;},&lt;br /&gt; {ri!attachmentDetailsId, ri!folderId}&lt;br /&gt; )&lt;br /&gt; )&lt;/p&gt;
&lt;p&gt;&lt;span&gt;ri!attachmentDetailsId is an array&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;ri!attachment is attachment type array&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to update 2 CDT's with each other values in a process model</title><link>https://community.appian.com/thread/92041?ContentTypeID=1</link><pubDate>Wed, 09 Mar 2022 18:42:00 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:018d995a-2633-4e30-95cd-d68221c34da0</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;You can directly assign lists to lists. Give it a try. In case it does not work, please attach some screenshots of your process node configurations.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>