<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Combining Collections by code, works in VS not in BP. in Product Forum</title>
    <link>https://community.blueprism.com/t5/Product-Forum/Combining-Collections-by-code-works-in-VS-not-in-BP/m-p/89914#M40233</link>
    <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I have to merge two collections horizontally (So add the columns of collection x to the right of the columns of collection y). I wrote some code for this which works fine in Visual Studio but gives me problems in Blue Prism.&lt;BR /&gt;I get the message that there is no conversion possible from collection to text.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The code in BP is as follows (appendDt is the collection to append, mainDt is the collection to append to, collOut is the merged output collection):&lt;BR /&gt;--------------------------------------------------------------------------------------------------&lt;BR /&gt;sErrorMsg = "";&lt;BR /&gt;bError = false;&lt;BR /&gt;&lt;BR /&gt;try&lt;BR /&gt;{
&lt;DIV style="padding-left: 40px;"&gt;for (int i = 0; i &amp;lt; appendDt.Columns.Count; i++)&lt;/DIV&gt;
&lt;DIV style="padding-left: 40px;"&gt;{&lt;/DIV&gt;
&lt;DIV style="padding-left: 80px;"&gt;mainDt.Columns.Add(appendDt.Columns&lt;I&gt;.ColumnName.ToString(), appendDt.Columns&lt;I&gt;.DataType);&lt;/I&gt;&lt;/I&gt;&lt;/DIV&gt;
&lt;DIV style="padding-left: 40px;"&gt;}&lt;/DIV&gt;
&lt;DIV style="padding-left: 40px;"&gt;for (int i = 0; i &amp;lt; mainDt.Rows.Count; i++)&lt;/DIV&gt;
&lt;DIV style="padding-left: 40px;"&gt;{&lt;/DIV&gt;
&lt;DIV style="padding-left: 80px;"&gt;for (int j = 0; j &amp;lt; appendDt.Columns.Count; j++)&lt;/DIV&gt;
&lt;DIV style="padding-left: 80px;"&gt;{&lt;/DIV&gt;
&lt;DIV style="padding-left: 120px;"&gt;mainDt.Rows&lt;I&gt;[appendDt.Columns[j].ColumnName.ToString()] = appendDt.Rows&lt;I&gt;[j];&lt;/I&gt;&lt;/I&gt;&lt;/DIV&gt;
&lt;DIV style="padding-left: 80px;"&gt;}&lt;/DIV&gt;
&lt;DIV style="padding-left: 40px;"&gt;}&lt;/DIV&gt;
&lt;P&gt;}&lt;BR /&gt;catch (Exception ex)&lt;BR /&gt;{&lt;BR /&gt;sErrorMsg = ex.Message;&lt;BR /&gt;bError = true;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;collOut = mainDt;&lt;BR /&gt;--------------------------------------------------------------------------------------------&lt;BR /&gt;&lt;BR /&gt;Further investigation in BP using MessageBox.Show between each line of code shows me that the problem arrises in the first "for" statement. I suspect BP's code engine does not recognize the COLLECTION.Columns.Count property but tries to find a field called Columns.Count in the input Collection/DataTable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What can I do?&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Thomas Warnaar&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
    <pubDate>Wed, 11 Aug 2021 09:01:00 GMT</pubDate>
    <dc:creator>Thomas_Warnaar_ZZ</dc:creator>
    <dc:date>2021-08-11T09:01:00Z</dc:date>
    <item>
      <title>Combining Collections by code, works in VS not in BP.</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Combining-Collections-by-code-works-in-VS-not-in-BP/m-p/89914#M40233</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I have to merge two collections horizontally (So add the columns of collection x to the right of the columns of collection y). I wrote some code for this which works fine in Visual Studio but gives me problems in Blue Prism.&lt;BR /&gt;I get the message that there is no conversion possible from collection to text.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The code in BP is as follows (appendDt is the collection to append, mainDt is the collection to append to, collOut is the merged output collection):&lt;BR /&gt;--------------------------------------------------------------------------------------------------&lt;BR /&gt;sErrorMsg = "";&lt;BR /&gt;bError = false;&lt;BR /&gt;&lt;BR /&gt;try&lt;BR /&gt;{
&lt;DIV style="padding-left: 40px;"&gt;for (int i = 0; i &amp;lt; appendDt.Columns.Count; i++)&lt;/DIV&gt;
&lt;DIV style="padding-left: 40px;"&gt;{&lt;/DIV&gt;
&lt;DIV style="padding-left: 80px;"&gt;mainDt.Columns.Add(appendDt.Columns&lt;I&gt;.ColumnName.ToString(), appendDt.Columns&lt;I&gt;.DataType);&lt;/I&gt;&lt;/I&gt;&lt;/DIV&gt;
&lt;DIV style="padding-left: 40px;"&gt;}&lt;/DIV&gt;
&lt;DIV style="padding-left: 40px;"&gt;for (int i = 0; i &amp;lt; mainDt.Rows.Count; i++)&lt;/DIV&gt;
&lt;DIV style="padding-left: 40px;"&gt;{&lt;/DIV&gt;
&lt;DIV style="padding-left: 80px;"&gt;for (int j = 0; j &amp;lt; appendDt.Columns.Count; j++)&lt;/DIV&gt;
&lt;DIV style="padding-left: 80px;"&gt;{&lt;/DIV&gt;
&lt;DIV style="padding-left: 120px;"&gt;mainDt.Rows&lt;I&gt;[appendDt.Columns[j].ColumnName.ToString()] = appendDt.Rows&lt;I&gt;[j];&lt;/I&gt;&lt;/I&gt;&lt;/DIV&gt;
&lt;DIV style="padding-left: 80px;"&gt;}&lt;/DIV&gt;
&lt;DIV style="padding-left: 40px;"&gt;}&lt;/DIV&gt;
&lt;P&gt;}&lt;BR /&gt;catch (Exception ex)&lt;BR /&gt;{&lt;BR /&gt;sErrorMsg = ex.Message;&lt;BR /&gt;bError = true;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;collOut = mainDt;&lt;BR /&gt;--------------------------------------------------------------------------------------------&lt;BR /&gt;&lt;BR /&gt;Further investigation in BP using MessageBox.Show between each line of code shows me that the problem arrises in the first "for" statement. I suspect BP's code engine does not recognize the COLLECTION.Columns.Count property but tries to find a field called Columns.Count in the input Collection/DataTable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What can I do?&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Thomas Warnaar&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Aug 2021 09:01:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Combining-Collections-by-code-works-in-VS-not-in-BP/m-p/89914#M40233</guid>
      <dc:creator>Thomas_Warnaar_ZZ</dc:creator>
      <dc:date>2021-08-11T09:01:00Z</dc:date>
    </item>
    <item>
      <title>RE: Combining Collections by code, works in VS not in BP.</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Combining-Collections-by-code-works-in-VS-not-in-BP/m-p/89915#M40234</link>
      <description>1) I'd remove try/catch to check exception.&lt;BR /&gt;2) You might hit a case where column with that name exists in original collection&lt;BR /&gt;3) I'd use foreach (probably not important)&lt;BR /&gt;4) Collection manipulation either had that action or I made my own, nevertheless code in VB:&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE class="language-markup"&gt;&lt;CODE&gt;For Each c As DataColumn in c2.Columns
	c1.Columns.Add(c.ColumnName, c.DataType)
Next

For r As Integer = 0 To c1.Rows.Count - 1
	If r &amp;lt; c2.Rows.Count Then
		For Each c As DataColumn in c2.Columns
			c1.Rows(r)(c.ColumnName) = c2.Rows(r)(c.ColumnName)
		Next
	Else
		Exit For
	End If
Next

c3 = c1​&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Andrey Kudinov&lt;BR /&gt;Project Manager&lt;BR /&gt;MobileTelesystems PJSC&lt;BR /&gt;Europe/Moscow&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Aug 2021 09:59:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Combining-Collections-by-code-works-in-VS-not-in-BP/m-p/89915#M40234</guid>
      <dc:creator>AndreyKudinov</dc:creator>
      <dc:date>2021-08-11T09:59:00Z</dc:date>
    </item>
    <item>
      <title>RE: Combining Collections by code, works in VS not in BP.</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Combining-Collections-by-code-works-in-VS-not-in-BP/m-p/89916#M40235</link>
      <description>Isn't the "Merge Collection" -action from Blue Prism's native Utility - Collection Manipulation -object doing exactly what you want to achieve?&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Ismo Lehtiniemi&lt;BR /&gt;RPA Architect &amp;amp; Solution Expert&lt;BR /&gt;Amcor&lt;BR /&gt;Europe/Warsaw&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Aug 2021 10:05:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Combining-Collections-by-code-works-in-VS-not-in-BP/m-p/89916#M40235</guid>
      <dc:creator>IsmoLehtiniemi</dc:creator>
      <dc:date>2021-08-11T10:05:00Z</dc:date>
    </item>
    <item>
      <title>RE: Combining Collections by code, works in VS not in BP.</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Combining-Collections-by-code-works-in-VS-not-in-BP/m-p/89917#M40236</link>
      <description>&lt;a href="https://community.blueprism.com/t5/user/viewprofilepage/user-id/1242"&gt;@IsmoLehtiniemi&lt;/a&gt; Yeah indeed! I think I missed that because when I tried that one I made it cast the merged collection to one of the original collections, which didn't work because the field definitions don't match. &lt;BR /&gt;&lt;BR /&gt;Now I tried casting it to a new colelction and it works as it should. Thanks!​&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Thomas Warnaar&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Aug 2021 10:24:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Combining-Collections-by-code-works-in-VS-not-in-BP/m-p/89917#M40236</guid>
      <dc:creator>Thomas_Warnaar_ZZ</dc:creator>
      <dc:date>2021-08-11T10:24:00Z</dc:date>
    </item>
  </channel>
</rss>

