cancel
Showing results for 
Search instead for 
Did you mean: 

Combo of Merge Collections and Append Rows to Collection

MarshallMclane
Level 5
Hi,

I need some help. I am trying to join / merge two collections.  I cant append rows to collection because the field types are not exactly the same between the two collections.. Also I can not use merge collections because they do have field names in common.  Is there a middle ground that joins collections with some similar columns and some columns that are different names or types? Thanks

------------------------------
Marshall Mclane
Automation Developer
Capital Group
America/Los_Angeles
------------------------------
1 REPLY 1

NicholasZejdlik
Level 9
I came across that situation; I don't think there is anything in the stock objects, I had to write a custom code stage:
' Inputs: Collection A, Collection B
' Outputs: Collection Out

Collection_Out = Collection_A

For Each Column As DataColumn In Collection_B.Columns
	If Not Collection_Out.Columns.Contains(Column.ColumnName) Then
		Collection_Out.Columns.Add(Column.ColumnName, Column.DataType)
	End If
Next

For Each Row As DataRow In Collection_B.Rows
	Dim NewRow As DataRow = Collection_Out.NewRow
	For Each Column As DataColumn In Collection_B.Columns
		NewRow(Column.ColumnName) = Row(Column.ColumnName)
	Next
	Collection_Out.Rows.Add(NewRow)
Next​


------------------------------
Nicholas Zejdlik
RPA Developer
------------------------------