<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic #BPTechTips - Wondered How Collections Can Be Used As Dictionaries! in Product Forum</title>
    <link>https://community.blueprism.com/t5/Product-Forum/BPTechTips-Wondered-How-Collections-Can-Be-Used-As-Dictionaries/m-p/62279#M15422</link>
    <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;A small hack that I use especially for reading configuration files at times where I convert the usage of my &lt;STRONG&gt;collection similar to that of a dictionary&lt;/STRONG&gt;.&lt;BR /&gt;&lt;BR /&gt;Suppose I have a configuration file like shown below:&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="26733.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/26859i5CF3C86274509689/image-size/large?v=v2&amp;amp;px=999" role="button" title="26733.png" alt="26733.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;Now comes the little hack that I do!!&lt;BR /&gt;&lt;BR /&gt;Create a custom action by extending the Collection Manipulation VBO with the below code:&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="26734.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/26865iDCB76F7D758D143F/image-size/large?v=v2&amp;amp;px=999" role="button" title="26734.png" alt="26734.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="26735.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/26866i8475A058E5A0009D/image-size/large?v=v2&amp;amp;px=999" role="button" title="26735.png" alt="26735.png" /&gt;&lt;/span&gt;&lt;BR /&gt;Use the below code :&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;Dim newRow As System.Data.DataRow&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;For each row as System.Data.DataRow In Collections.Rows&lt;/CODE&gt;&lt;BR /&gt;&lt;CODE&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; newCollection.Columns.Add(CStr(row("Name")) ,GetType(String))&lt;/CODE&gt;&lt;BR /&gt;&lt;CODE&gt;Next&lt;/CODE&gt;&lt;BR /&gt;&lt;CODE&gt;newRow = newCollection.NewRow()&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;For each column as System.Data.DataColumn In newCollection.Columns&lt;/CODE&gt;&lt;BR /&gt;&lt;CODE&gt;&amp;nbsp; &amp;nbsp; For each row as System.Data.DataRow In Collections.Rows&lt;/CODE&gt;&lt;BR /&gt;&lt;CODE&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;If CStr(row(0))=column.ColumnName&lt;/CODE&gt;&lt;BR /&gt;&lt;CODE&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; newRow(column.ColumnName)=CStr(row(1))&lt;/CODE&gt;&lt;BR /&gt;&lt;CODE&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;End If&lt;/CODE&gt;&lt;BR /&gt;&lt;CODE&gt;&amp;nbsp; &amp;nbsp; Next&lt;/CODE&gt;&lt;BR /&gt;&lt;CODE&gt;Next&lt;BR /&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;CODE&gt;newCollection.Rows.Add(newRow)&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Let us see the results shall we:&lt;BR /&gt;&lt;BR /&gt;After reading the excel file:&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="26736.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/26867i1FFBA31AADBDA179/image-size/large?v=v2&amp;amp;px=999" role="button" title="26736.png" alt="26736.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Post calling the action:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="26737.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/26871i18AC2B26B31E5FC8/image-size/large?v=v2&amp;amp;px=999" role="button" title="26737.png" alt="26737.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;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: &lt;STRONG&gt;&lt;EM&gt;"Provide a key, get the value"&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/STRONG&gt;Let me know if you like it!&lt;BR /&gt;&lt;BR /&gt;&lt;A data-tag-text="BPTechTips" data-sign="#" class="user-content-hashtag" href="https://community.blueprism.com/search?s=tags%3A%22BPTechTips%22&amp;amp;executesearch=true" data-tag-key="96c6fa99-5a9a-4919-98a6-d9ce55afe99f"&gt;#BPTechTips&lt;/A&gt; &lt;A data-tag-text="Quick_Tip" data-sign="#" class="user-content-hashtag" href="https://community.blueprism.com/search?s=tags%3A%22Quick_Tip%22&amp;amp;executesearch=true" data-tag-key="14320b6e-b4aa-4152-8b29-1c759213a292"&gt;#Quick_Tip&lt;/A&gt;​&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Regards,&lt;BR /&gt;Devneet Mohanty&lt;BR /&gt;Intelligent Automation Consultant&lt;BR /&gt;Blueprism 6x Certified Professional&lt;BR /&gt;Website: &lt;A href="https://devneet.github.io/" target="test_blank"&gt;https://devneet.github.io/&lt;/A&gt;&lt;BR /&gt;Email: devneetmohanty07@gmail.com&lt;BR /&gt;------------------------------&lt;BR /&gt;​</description>
    <pubDate>Mon, 29 Nov 2021 16:54:00 GMT</pubDate>
    <dc:creator>devneetmohanty07</dc:creator>
    <dc:date>2021-11-29T16:54:00Z</dc:date>
    <item>
      <title>#BPTechTips - Wondered How Collections Can Be Used As Dictionaries!</title>
      <link>https://community.blueprism.com/t5/Product-Forum/BPTechTips-Wondered-How-Collections-Can-Be-Used-As-Dictionaries/m-p/62279#M15422</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;A small hack that I use especially for reading configuration files at times where I convert the usage of my &lt;STRONG&gt;collection similar to that of a dictionary&lt;/STRONG&gt;.&lt;BR /&gt;&lt;BR /&gt;Suppose I have a configuration file like shown below:&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="26733.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/26859i5CF3C86274509689/image-size/large?v=v2&amp;amp;px=999" role="button" title="26733.png" alt="26733.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;Now comes the little hack that I do!!&lt;BR /&gt;&lt;BR /&gt;Create a custom action by extending the Collection Manipulation VBO with the below code:&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="26734.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/26865iDCB76F7D758D143F/image-size/large?v=v2&amp;amp;px=999" role="button" title="26734.png" alt="26734.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="26735.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/26866i8475A058E5A0009D/image-size/large?v=v2&amp;amp;px=999" role="button" title="26735.png" alt="26735.png" /&gt;&lt;/span&gt;&lt;BR /&gt;Use the below code :&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;Dim newRow As System.Data.DataRow&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;For each row as System.Data.DataRow In Collections.Rows&lt;/CODE&gt;&lt;BR /&gt;&lt;CODE&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; newCollection.Columns.Add(CStr(row("Name")) ,GetType(String))&lt;/CODE&gt;&lt;BR /&gt;&lt;CODE&gt;Next&lt;/CODE&gt;&lt;BR /&gt;&lt;CODE&gt;newRow = newCollection.NewRow()&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;For each column as System.Data.DataColumn In newCollection.Columns&lt;/CODE&gt;&lt;BR /&gt;&lt;CODE&gt;&amp;nbsp; &amp;nbsp; For each row as System.Data.DataRow In Collections.Rows&lt;/CODE&gt;&lt;BR /&gt;&lt;CODE&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;If CStr(row(0))=column.ColumnName&lt;/CODE&gt;&lt;BR /&gt;&lt;CODE&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; newRow(column.ColumnName)=CStr(row(1))&lt;/CODE&gt;&lt;BR /&gt;&lt;CODE&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;End If&lt;/CODE&gt;&lt;BR /&gt;&lt;CODE&gt;&amp;nbsp; &amp;nbsp; Next&lt;/CODE&gt;&lt;BR /&gt;&lt;CODE&gt;Next&lt;BR /&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;CODE&gt;newCollection.Rows.Add(newRow)&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Let us see the results shall we:&lt;BR /&gt;&lt;BR /&gt;After reading the excel file:&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="26736.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/26867i1FFBA31AADBDA179/image-size/large?v=v2&amp;amp;px=999" role="button" title="26736.png" alt="26736.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Post calling the action:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="26737.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/26871i18AC2B26B31E5FC8/image-size/large?v=v2&amp;amp;px=999" role="button" title="26737.png" alt="26737.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;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: &lt;STRONG&gt;&lt;EM&gt;"Provide a key, get the value"&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/STRONG&gt;Let me know if you like it!&lt;BR /&gt;&lt;BR /&gt;&lt;A data-tag-text="BPTechTips" data-sign="#" class="user-content-hashtag" href="https://community.blueprism.com/search?s=tags%3A%22BPTechTips%22&amp;amp;executesearch=true" data-tag-key="96c6fa99-5a9a-4919-98a6-d9ce55afe99f"&gt;#BPTechTips&lt;/A&gt; &lt;A data-tag-text="Quick_Tip" data-sign="#" class="user-content-hashtag" href="https://community.blueprism.com/search?s=tags%3A%22Quick_Tip%22&amp;amp;executesearch=true" data-tag-key="14320b6e-b4aa-4152-8b29-1c759213a292"&gt;#Quick_Tip&lt;/A&gt;​&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Regards,&lt;BR /&gt;Devneet Mohanty&lt;BR /&gt;Intelligent Automation Consultant&lt;BR /&gt;Blueprism 6x Certified Professional&lt;BR /&gt;Website: &lt;A href="https://devneet.github.io/" target="test_blank"&gt;https://devneet.github.io/&lt;/A&gt;&lt;BR /&gt;Email: devneetmohanty07@gmail.com&lt;BR /&gt;------------------------------&lt;BR /&gt;​</description>
      <pubDate>Mon, 29 Nov 2021 16:54:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/BPTechTips-Wondered-How-Collections-Can-Be-Used-As-Dictionaries/m-p/62279#M15422</guid>
      <dc:creator>devneetmohanty07</dc:creator>
      <dc:date>2021-11-29T16:54:00Z</dc:date>
    </item>
    <item>
      <title>RE: #BPTechTips - Wondered How Collections Can Be Used As Dictionaries!</title>
      <link>https://community.blueprism.com/t5/Product-Forum/BPTechTips-Wondered-How-Collections-Can-Be-Used-As-Dictionaries/m-p/62280#M15423</link>
      <description>I really liked it. Try it for sure.&lt;BR /&gt;Currently, I perform such a task for configuration files using Append Field action to transpose collection.&lt;BR /&gt;Thanks for sharing.&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Thanks &amp;amp; Regards,&lt;BR /&gt;Tejaskumar Darji&lt;BR /&gt;Sr. RPA Consultant-Automation Developer&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Tue, 30 Nov 2021 13:59:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/BPTechTips-Wondered-How-Collections-Can-Be-Used-As-Dictionaries/m-p/62280#M15423</guid>
      <dc:creator>Tejaskumar_Darji</dc:creator>
      <dc:date>2021-11-30T13:59:00Z</dc:date>
    </item>
  </channel>
</rss>

