Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in RPA by (5.3k points)

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.

1 Answer

0 votes
by (12.7k points)

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:

  1. Action: Get Column Names

    • Object: Utility - Collection Manipulation
    • Input: My_Collection
    • Output: Column Names - My_Collection (Collection)
  2. Loop Start

    • Collection: Column Names - My_Collection
  3. Action: Count Columns

    • Object: Internal -> Collections
    • Input: "My_Collection"
    • Output: Count of Columns - My_Collection (Number)
  4. Decision: Is this the last Column?

    • Expression: [Count of Columns - My_Collection] <= 1
    • Yes path: #7
    • No path: #5
  5. Action: Delete Column

    • Object: Utility - Collection Manipulation
    • Input (Input Collection): [My_Collection]
    • Input (Column Name): [Column Names - My_Collection.Field Name]
    • Output (Output Collection): [My_Collection]
  6. Loop End

  7. Action: Rename Field

    • Object: Utility - Collection Manipulation
    • Input (Collection In): My_Collection
    • Input (Field Name): [Column Names - My_Collection.Field Name]
    • Input (New Name): "Result" (or a name of your choice)
    • Output (Output Collection): [My_Collection]
  8. Loop Start

    • Collection: My_Collection
  9. Processing Logic

    • Use expression [My_Collection.Result] to refer to the value in the current row
  10. Loop End

Interested in RPA ? Check out this RPA Certification by Intellipaat.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...