28-12-20 12:45 PM
Can you help me, I would like to create new field with specific BP type. return as collection appended field.
I suppose to support all type that BP collection allowed.
Here a snip code I want to add Time field to collection but It doesn't work, The collection return as DateTime field instead.
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
BP field types: (At least I need to create column with Time, TimeSpan, Password)
Answered! Go to Answer.
28-12-20 08:52 PM
Hi,
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.
Type columnType;
System.Data.DataTable table = new System.Data.DataTable();
Success = true;
ErrorMessage = "";
columnType = null;
outputColl = inputColl;
try{
switch (fieldType){
case "collection":
columnType = typeof(System.Data.DataTable);
break;
case "datetime":
columnType = typeof(DateTime);
break;
case "flag":
columnType = typeof(Boolean);
break;
case "number":
columnType = typeof(System.Decimal);
break;
case "text":
columnType = typeof(String);
break;
case "timespan":
columnType = typeof(TimeSpan);
break;
case "binary":
columnType = typeof(Byte[]);
break;
case "image":
columnType = typeof(System.Drawing.Bitmap);
break;
default:
Success = false;
ErrorMessage = "Invalid data type presented";
break;
}
if (success){
table = inputColl;
table.Columns.Add(name,columnType);
outputColl = table;
}
}catch (Exception ex){
Success = false;
ErrorMessage = ex.Message;
}
Regards,
28-12-20 08:52 PM
Hi,
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.
Type columnType;
System.Data.DataTable table = new System.Data.DataTable();
Success = true;
ErrorMessage = "";
columnType = null;
outputColl = inputColl;
try{
switch (fieldType){
case "collection":
columnType = typeof(System.Data.DataTable);
break;
case "datetime":
columnType = typeof(DateTime);
break;
case "flag":
columnType = typeof(Boolean);
break;
case "number":
columnType = typeof(System.Decimal);
break;
case "text":
columnType = typeof(String);
break;
case "timespan":
columnType = typeof(TimeSpan);
break;
case "binary":
columnType = typeof(Byte[]);
break;
case "image":
columnType = typeof(System.Drawing.Bitmap);
break;
default:
Success = false;
ErrorMessage = "Invalid data type presented";
break;
}
if (success){
table = inputColl;
table.Columns.Add(name,columnType);
outputColl = table;
}
}catch (Exception ex){
Success = false;
ErrorMessage = ex.Message;
}
Regards,
29-12-20 02:32 PM
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).