<?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 convert array into single value against a single key</title><link>https://community.appian.com/discussions/f/general/18837/how-to-convert-array-into-single-value-against-a-single-key</link><description>I&amp;#39;ve CDT which has data like {ID:1, Val: &amp;quot;A,B,C}. Now I want to store the values in another CDT and write to DB where I want to save them in manner like {ID:1, Val:&amp;quot;A&amp;quot;, ID:1, Val:&amp;quot;B&amp;quot;,ID:1, Val:&amp;quot;C&amp;quot;}. What can be done to achieve this. 
 
 Regards: Nite</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to convert array into single value against a single key</title><link>https://community.appian.com/thread/74085?ContentTypeID=1</link><pubDate>Thu, 14 May 2020 14:41:23 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c69ef204-1b61-4e19-ac35-fa8e942570b6</guid><dc:creator>davel001150</dc:creator><description>&lt;p&gt;No!&amp;nbsp; I realize what you need to do!&amp;nbsp; Specifically because you want to write to database.&lt;/p&gt;
&lt;p&gt;If I understand your question correctly you have:&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;ID: 1,&lt;/p&gt;
&lt;p&gt;Val: &amp;quot;A, B, C&amp;quot;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;and you want A, B, C to each get their own row with a 1 foreign key?&amp;nbsp; Just split the string. Use split() on &amp;quot;A,B,C&amp;quot; with the comma as your separator, and you should wind up with:&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;ID: 1&lt;/p&gt;
&lt;p&gt;Val: {&amp;quot;A&amp;quot;;&amp;quot;B&amp;quot;;&amp;quot;C&amp;quot;}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;And Appian should automatically save that in DB how you would want it to be saved.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert array into single value against a single key</title><link>https://community.appian.com/thread/74082?ContentTypeID=1</link><pubDate>Thu, 14 May 2020 14:35:52 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ad001a97-b40d-4275-b53c-d64207e6f56c</guid><dc:creator>davel001150</dc:creator><description>&lt;p&gt;Or does merge(1, {A,B,C}) just return {{1,A},B,C}?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert array into single value against a single key</title><link>https://community.appian.com/thread/74079?ContentTypeID=1</link><pubDate>Thu, 14 May 2020 14:34:16 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e78d5bda-89c2-44d7-8dbb-928f547ed899</guid><dc:creator>davel001150</dc:creator><description>&lt;p&gt;If I still remember my good ol&amp;#39; merge() function, which I haven&amp;#39;t had to much use since a!forEach, merge(1, {A, B, C}) should result in {{1, A},{1, B},{1, C}}&lt;/p&gt;
&lt;p&gt;Does that lead you in the direction you want to go?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert array into single value against a single key</title><link>https://community.appian.com/thread/74047?ContentTypeID=1</link><pubDate>Wed, 13 May 2020 14:53:28 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:518f5a8f-b3c2-4518-a1c1-dbd80318ea34</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;You can&amp;#39;t have multiple properties with the same name (i.e. &amp;quot;Val&amp;quot;) in a CDT, nor can you really have a variable number of properties (though there&amp;#39;s nothing keeping you from adding the maximum number that you&amp;#39;ll ever likely need).&amp;nbsp; They would need unique names, like {val1, val2, val3} etc.&lt;/p&gt;
&lt;p&gt;If the list of &amp;quot;Val&amp;quot; is going to be completely variable then you might want to consider making an association table where you add a new row for each one, where each row has a reference to the &amp;quot;ID&amp;quot;, and a reference to the &amp;quot;Val&amp;quot; value.&amp;nbsp; This table would also need its own primary key, separate from the original &amp;quot;ID&amp;quot;.&lt;/p&gt;
&lt;p&gt;But at this point your use case is not clear enough and it&amp;#39;s getting to be too much guesswork to say anything specific about it without potentially going in the wrong direction.&amp;nbsp; Is there any more detail you can provide as to the nature of your input data and what you need it transformed into?&amp;nbsp; Would &amp;quot;A,B,C&amp;quot; be literally a comma-separated single text value, or would it be an array, for example?&amp;nbsp; How long would it get?&amp;nbsp; These are just a few points of clarification needed to really be helpful for you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>