<?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>Save row values of one CDT as column values of another CDT</title><link>https://community.appian.com/discussions/f/data/24452/save-row-values-of-one-cdt-as-column-values-of-another-cdt</link><description>Hi Team, I have a CDT in the below format : 
 id , item id, field name, field value, field seq no where id is the primary key. Eg of values : 1, 1, Name, Alex, 1 
 2, 1, Age, 45, 2 
 3, 1, DOJ, 2022-04-05 08:56:00, 3 
 4, 1, Designation, Engineer, 5 </description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Save row values of one CDT as column values of another CDT</title><link>https://community.appian.com/thread/94410?ContentTypeID=1</link><pubDate>Mon, 02 May 2022 13:12:04 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:95069448-7cc6-45bd-84ba-b55a8e5dee21</guid><dc:creator>davel001150</dc:creator><description>&lt;p&gt;Choose should work fine so long as you have the maximum possible value in the choose function.&amp;nbsp; It is iterative in a sense, because for each individual value, you pick the location to save to in CDT 2.&amp;nbsp; So if you have sequences 5, 17, 4, as long as the choose goes at least up to 17, the forEach loop will return &amp;quot;value5&amp;quot;, &amp;quot;value17&amp;quot;, &amp;quot;value4&amp;quot;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Now, if the name of the place that you&amp;#39;re supposed to save a &amp;quot;5&amp;quot; changes depending on the size of the CDT, that&amp;#39;s a nightmare I don&amp;#39;t want to think about right now.&amp;nbsp; In that case, you might have to create a gigantic if() nest, or if the sets of possibilities is finite in length, you might consider a Decision object.&lt;/p&gt;
&lt;p&gt;Also, you can use updateCDT to achieve similar effect, but a!update is better.&amp;nbsp; You&amp;#39;ll probably have to a!forEach to create each individual updateCDT statement.&amp;nbsp; Consider upgrade, or telling others that you should upgrade.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Save row values of one CDT as column values of another CDT</title><link>https://community.appian.com/thread/94394?ContentTypeID=1</link><pubDate>Mon, 02 May 2022 04:44:20 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3a35da15-7946-4cd3-a799-4f8af7db9b91</guid><dc:creator>SS</dc:creator><description>&lt;p&gt;Hi Dave,&lt;/p&gt;
&lt;p&gt;Thank you for your suggestion.&lt;/p&gt;
&lt;p&gt;I had few queries more related to the same.&lt;/p&gt;
&lt;p&gt;1. For choose, I want to use an iterative value as my choice values because sometimes CDT1 can have 5 items, sometimes 3, sometimes 20 or more. No constant value for the number of items in CDT1.&lt;/p&gt;
&lt;p&gt;2. Also CDT2 will be null in starting. As an user inputs value in form that shows data from CDT1, the row would get added in CDT2.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Any suggestions on the above will help me out!!&lt;br /&gt;Appian version I use is 21.1 and we do not have update() function in it.&lt;/p&gt;
&lt;p&gt;Thanks in advance!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Save row values of one CDT as column values of another CDT</title><link>https://community.appian.com/thread/94340?ContentTypeID=1</link><pubDate>Fri, 29 Apr 2022 13:48:48 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:cfe62add-bfc9-4378-afed-e61db5c8bf00</guid><dc:creator>davel001150</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!save( 
    CDT2,
    update(
        data: CDT2,
        index: a!forEach(
            items: CDT1.fieldSeq,
            expression:choose(key: fv!item, choice1: &amp;quot;value1&amp;quot;, choice2: &amp;quot;value2&amp;quot;...),
        )/* a!forEach returns a list, in this case a list of indeces */
        value: CDT1.fieldValue /*list of values goes into list of indeces*/
    )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Bear in mind this is pseudo-code that I&amp;#39;m not trying to test out with the above scenario.&amp;nbsp; Also keep in mind that choose function requires that every value from 1 to n be represented.&amp;nbsp; If you have a 5, you also must have 4, 3, 2, and 1.&amp;nbsp; You can&amp;#39;t skip any.&amp;nbsp; It doesn&amp;#39;t look like you do, so it&amp;#39;s a good use case for choose.&lt;/p&gt;
&lt;p&gt;Let us know if it works.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>