<?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 Re: How to append new field to collection with specific field type? in Product Forum</title>
    <link>https://community.blueprism.com/t5/Product-Forum/How-to-append-new-field-to-collection-with-specific-field-type/m-p/101006#M48122</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;
&lt;/P&gt;&lt;P&gt;I've got C# code (not all BP field types are created but you will get an idea) which you can rewrite to VB. Not sure about password as it will be probably taking some has from BP itself.&lt;/P&gt;
&lt;P&gt;
&lt;/P&gt;&lt;P&gt;Type columnType;&lt;BR /&gt;System.Data.DataTable table = new System.Data.DataTable();&lt;/P&gt;
&lt;P&gt;Success = true;&lt;BR /&gt;ErrorMessage = "";&lt;BR /&gt;columnType = null;&lt;BR /&gt;outputColl = inputColl;&lt;/P&gt;
&lt;P&gt;try{&lt;/P&gt;
&lt;P&gt;switch (fieldType){&lt;/P&gt;
&lt;P&gt;case "collection":&lt;BR /&gt;columnType = typeof(System.Data.DataTable);&lt;BR /&gt;break;&lt;/P&gt;
&lt;P&gt;case "datetime":&lt;BR /&gt;columnType = typeof(DateTime);&lt;BR /&gt;break;&lt;/P&gt;
&lt;P&gt;case "flag":&lt;BR /&gt;columnType = typeof(Boolean);&lt;BR /&gt;break;&lt;/P&gt;
&lt;P&gt;case "number":&lt;BR /&gt;columnType = typeof(System.Decimal);&lt;BR /&gt;break;&lt;/P&gt;
&lt;P&gt;case "text":&lt;BR /&gt;columnType = typeof(String);&lt;BR /&gt;break;&lt;/P&gt;
&lt;P&gt;case "timespan":&lt;BR /&gt;columnType = typeof(TimeSpan);&lt;BR /&gt;break;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;case "binary":&lt;BR /&gt;columnType = typeof(Byte[]);&lt;BR /&gt;break;&lt;BR /&gt;case "image":&lt;BR /&gt;columnType = typeof(System.Drawing.Bitmap);&lt;BR /&gt;break;&lt;BR /&gt;default:&lt;BR /&gt;Success = false;&lt;BR /&gt;ErrorMessage = "Invalid data type presented";&lt;BR /&gt;break;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;if (success){&lt;BR /&gt;table = inputColl;&lt;BR /&gt;table.Columns.Add(name,columnType);&lt;BR /&gt;outputColl = table;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;}catch (Exception ex){&lt;BR /&gt;Success = false;&lt;BR /&gt;ErrorMessage = ex.Message;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Dec 2020 20:52:16 GMT</pubDate>
    <dc:creator>zdenek.kabatek</dc:creator>
    <dc:date>2020-12-28T20:52:16Z</dc:date>
    <item>
      <title>How to append new field to collection with specific field type?</title>
      <link>https://community.blueprism.com/t5/Product-Forum/How-to-append-new-field-to-collection-with-specific-field-type/m-p/101005#M48121</link>
      <description>&lt;P&gt;Can you help me, I would like to create new field with specific BP type. return as collection appended field.&lt;/P&gt;
&lt;P&gt;I suppose to support all type that BP collection allowed.&lt;/P&gt;
&lt;P&gt;Here a snip code I want to add Time field to collection but It doesn't work, The collection return as DateTime field instead.&lt;/P&gt;
&lt;PRE class="language-markup"&gt;&lt;CODE&gt;If Not Collection.Columns.Contains(Column) Then
Value = DateTime.SpecifyKind(Value, DateTimeKind.Utc)

Dim newc As DataColumn = New DataColumn
newc.DataType = GetType(DateTime)
newc.AllowDBNull = False
newc.Caption = Column
newc.ColumnName = Column
newc.DateTimeMode = DataSetDateTime.Utc
newc.DefaultValue = Value
newc.ExtendedProperties().Add("bptype", "time")
Collection.Columns.Add(newc)
End If

New_Collection = Collection&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;
&lt;/P&gt;&lt;P&gt;BP field types: (At least I need to create column with Time, TimeSpan, Password)&lt;/P&gt;
&lt;P class="media" style="overflow: hidden"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="36614.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/36621iEA56D47218788189/image-size/large?v=v2&amp;amp;px=999" role="button" title="36614.png" alt="36614.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2020 12:45:25 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/How-to-append-new-field-to-collection-with-specific-field-type/m-p/101005#M48121</guid>
      <dc:creator>pitchaya.yamprai</dc:creator>
      <dc:date>2020-12-28T12:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to append new field to collection with specific field type?</title>
      <link>https://community.blueprism.com/t5/Product-Forum/How-to-append-new-field-to-collection-with-specific-field-type/m-p/101006#M48122</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;
&lt;/P&gt;&lt;P&gt;I've got C# code (not all BP field types are created but you will get an idea) which you can rewrite to VB. Not sure about password as it will be probably taking some has from BP itself.&lt;/P&gt;
&lt;P&gt;
&lt;/P&gt;&lt;P&gt;Type columnType;&lt;BR /&gt;System.Data.DataTable table = new System.Data.DataTable();&lt;/P&gt;
&lt;P&gt;Success = true;&lt;BR /&gt;ErrorMessage = "";&lt;BR /&gt;columnType = null;&lt;BR /&gt;outputColl = inputColl;&lt;/P&gt;
&lt;P&gt;try{&lt;/P&gt;
&lt;P&gt;switch (fieldType){&lt;/P&gt;
&lt;P&gt;case "collection":&lt;BR /&gt;columnType = typeof(System.Data.DataTable);&lt;BR /&gt;break;&lt;/P&gt;
&lt;P&gt;case "datetime":&lt;BR /&gt;columnType = typeof(DateTime);&lt;BR /&gt;break;&lt;/P&gt;
&lt;P&gt;case "flag":&lt;BR /&gt;columnType = typeof(Boolean);&lt;BR /&gt;break;&lt;/P&gt;
&lt;P&gt;case "number":&lt;BR /&gt;columnType = typeof(System.Decimal);&lt;BR /&gt;break;&lt;/P&gt;
&lt;P&gt;case "text":&lt;BR /&gt;columnType = typeof(String);&lt;BR /&gt;break;&lt;/P&gt;
&lt;P&gt;case "timespan":&lt;BR /&gt;columnType = typeof(TimeSpan);&lt;BR /&gt;break;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;case "binary":&lt;BR /&gt;columnType = typeof(Byte[]);&lt;BR /&gt;break;&lt;BR /&gt;case "image":&lt;BR /&gt;columnType = typeof(System.Drawing.Bitmap);&lt;BR /&gt;break;&lt;BR /&gt;default:&lt;BR /&gt;Success = false;&lt;BR /&gt;ErrorMessage = "Invalid data type presented";&lt;BR /&gt;break;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;if (success){&lt;BR /&gt;table = inputColl;&lt;BR /&gt;table.Columns.Add(name,columnType);&lt;BR /&gt;outputColl = table;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;}catch (Exception ex){&lt;BR /&gt;Success = false;&lt;BR /&gt;ErrorMessage = ex.Message;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2020 20:52:16 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/How-to-append-new-field-to-collection-with-specific-field-type/m-p/101006#M48122</guid>
      <dc:creator>zdenek.kabatek</dc:creator>
      <dc:date>2020-12-28T20:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to append new field to collection with specific field type?</title>
      <link>https://community.blueprism.com/t5/Product-Forum/How-to-append-new-field-to-collection-with-specific-field-type/m-p/101007#M48123</link>
      <description>&lt;P&gt;To add to Zdenek's excellent answer, I don't believe you can programmatically create a collection with types of Date, Time and Password. Date and Time are actually both DateTime, and Password is String; Blue Prism will pick them up as such. The good news is it doesn't matter; anything you do to a Date or to a Time, you can do to a DateTime, and String will work just as well as Password, it just won't be masked (it is not exactly difficult to unmask a Password anyway).&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2020 14:32:33 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/How-to-append-new-field-to-collection-with-specific-field-type/m-p/101007#M48123</guid>
      <dc:creator>NicholasZejdlik</dc:creator>
      <dc:date>2020-12-29T14:32:33Z</dc:date>
    </item>
  </channel>
</rss>

