cancel
Showing results for 
Search instead for 
Did you mean: 

Inrechange column

pankaj
Level 2
1)how to interchange column from collection

------------------------------
pankaj sarak
------------------------------
1 BEST ANSWER

Best Answers

Hi Pankaj,

You can extend the 'Collection Manipulation' business object by creating a new action named 'Set Column Order' and pass two input arguments, 'Original Collection' (Collection) and 'Column Order Collection' (Collection) having a single column called 'Column Name' of text data type. Based on the order of how you set up all the column names in each row from top to bottom, the columns will get rearranged in the Original Collection. Also set an Output parameter as 'Output Collection' (Collection) for this action as shown below:

204.png

Add the code stage and use the below code with the input and out arguments as show:

dim i as Integer

i=0

For Each dr as DataRow in col_order_DT.Rows
	origDT.Columns(""+dr(0).ToString()+"").SetOrdinal(i)
	i=i+1
Next

ordered_coll=origDT



205.png
206.png

207.png

The run results are as follows:

Input Arguments:

208.png

209.png

Since, here I have maintained the order of column names  (Top To Bottom) as Field3, Field2,Field4 and Field1 hence my output collection will also have the same order

Output Result:

210.png

You can publish the action and test the same from Process Studio. Let us know if this helps you out 🙂



------------------------------
----------------------------------
Hope it helps you out and if my solution resolves your query, then please mark it as the 'Best Answer' so that the others members in the community having similar problem statement can track the answer easily in future

Regards,
Devneet Mohanty
Intelligent Process Automation Consultant | Sr. Consultant - Automation Developer,
WonderBotz India Pvt. Ltd.
Blue Prism Community MVP | Blue Prism 7x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com

----------------------------------
------------------------------
----------------------------------
Hope it helps you out and if my solution resolves your query, then please provide a big thumbs up so that the others members in the community having similar problem statement can track the answer easily in future.

Regards,
Devneet Mohanty
Intelligent Process Automation Consultant | Technical Business Analyst,
WonderBotz India Pvt. Ltd.
Blue Prism Community MVP | Blue Prism 7x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com

----------------------------------

View answer in original post

1 REPLY 1

Hi Pankaj,

You can extend the 'Collection Manipulation' business object by creating a new action named 'Set Column Order' and pass two input arguments, 'Original Collection' (Collection) and 'Column Order Collection' (Collection) having a single column called 'Column Name' of text data type. Based on the order of how you set up all the column names in each row from top to bottom, the columns will get rearranged in the Original Collection. Also set an Output parameter as 'Output Collection' (Collection) for this action as shown below:

204.png

Add the code stage and use the below code with the input and out arguments as show:

dim i as Integer

i=0

For Each dr as DataRow in col_order_DT.Rows
	origDT.Columns(""+dr(0).ToString()+"").SetOrdinal(i)
	i=i+1
Next

ordered_coll=origDT



205.png
206.png

207.png

The run results are as follows:

Input Arguments:

208.png

209.png

Since, here I have maintained the order of column names  (Top To Bottom) as Field3, Field2,Field4 and Field1 hence my output collection will also have the same order

Output Result:

210.png

You can publish the action and test the same from Process Studio. Let us know if this helps you out 🙂



------------------------------
----------------------------------
Hope it helps you out and if my solution resolves your query, then please mark it as the 'Best Answer' so that the others members in the community having similar problem statement can track the answer easily in future

Regards,
Devneet Mohanty
Intelligent Process Automation Consultant | Sr. Consultant - Automation Developer,
WonderBotz India Pvt. Ltd.
Blue Prism Community MVP | Blue Prism 7x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com

----------------------------------
------------------------------
----------------------------------
Hope it helps you out and if my solution resolves your query, then please provide a big thumbs up so that the others members in the community having similar problem statement can track the answer easily in future.

Regards,
Devneet Mohanty
Intelligent Process Automation Consultant | Technical Business Analyst,
WonderBotz India Pvt. Ltd.
Blue Prism Community MVP | Blue Prism 7x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com

----------------------------------