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:
![26733.png 26733.png](/t5/image/serverpage/image-id/26859i5CF3C86274509689/image-size/large?v=v2&px=999)
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:
![26734.png 26734.png](/t5/image/serverpage/image-id/26865iDCB76F7D758D143F/image-size/large?v=v2&px=999)
![26735.png 26735.png](/t5/image/serverpage/image-id/26866i8475A058E5A0009D/image-size/large?v=v2&px=999)
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:
![26736.png 26736.png](/t5/image/serverpage/image-id/26867i1FFBA31AADBDA179/image-size/large?v=v2&px=999)
Post calling the action:
![26737.png 26737.png](/t5/image/serverpage/image-id/26871i18AC2B26B31E5FC8/image-size/large?v=v2&px=999)
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 it helps you out and if my solution resolves your query, then please mark it as the best answer
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
----------------------------------