I have collection which gets populated during execution and hence has no Fields declared. I need to extract the values of last column, and number of columns is dynamic, and am not able to do so. How can I do this with or without using code stage? (Code: VB only, as I have other code blocks running VB)
I have tried to replace the value with another variable in calculation stage like this: [my_collection.[column_name]]. It's throwing an Error when I press on Validate expression.
It's frankly a bit overkill to use custom code stages for something this simple, especially considering the maintainability trade-off is almost always not going to be worth it in the long-run.
Using the Utility - Collection Manipulation
VBO, you can string the following actions together to achieve your desired functionality:
Action: Get Column Names
Utility - Collection Manipulation
My_Collection
Column Names - My_Collection
(Collection)Loop Start
Column Names - My_Collection
Action: Count Columns
Collections
"My_Collection"
Count of Columns - My_Collection
(Number)Decision: Is this the last Column?
[Count of Columns - My_Collection] <= 1
Yes
path: #7No
path: #5Action: Delete Column
Utility - Collection Manipulation
[My_Collection]
[Column Names - My_Collection.Field Name]
[My_Collection]
Loop End
Action: Rename Field
Utility - Collection Manipulation
My_Collection
[Column Names - My_Collection.Field Name]
"Result"
(or a name of your choice)[My_Collection]
Loop Start
My_Collection
Processing Logic
[My_Collection.Result]
to refer to the value in the current rowLoop End