Hi All,
A small hack that I use especially for reading configuration files at times where I convert the usage of my
collection similar to that of a dictionary.
Suppose I have a configuration file like shown below:
What I do is read the above table data into a collection by creating instance, opening workbook and reading the entire thing into a collection using 'Get Worksheet As Collection' action.
Now comes the little hack that I do!!
Create a custom action by extending the Collection Manipulation VBO with the below code:
Use the below code :
Dim newRow As System.Data.DataRow
For each row as System.Data.DataRow In Collections.Rows
newCollection.Columns.Add(CStr(row("Name")) ,GetType(String))
Next
newRow = newCollection.NewRow()
For each column as System.Data.DataColumn In newCollection.Columns
For each row as System.Data.DataRow In Collections.Rows
If CStr(row(0))=column.ColumnName
newRow(column.ColumnName)=CStr(row(1))
End If
Next
Next
newCollection.Rows.Add(newRow)
Let us see the results shall we:
After reading the excel file:
Post calling the action:
Now you can guess what is the best part here? If you need to use any configuration variable, simply write: [CollectionName.VariableName] and this way I am using my collection as a dictionary:
"Provide a key, get the value"
Let me know if you like it!
#BPTechTips #Quick_Tip
------------------------------
Regards,
Devneet Mohanty
Intelligent Automation Consultant
Blueprism 6x Certified Professional
Website:
https://devneet.github.io/Email: devneetmohanty07@gmail.com
------------------------------
---------------------------------------------------------------------------------------------------------------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.