I am building a BP object that does the following:
Blueprism seems to use c# DataTable objects for collections? I tried using List<> objects, but BP will not implicitly cast those (or anything else for that matter), so guess I have to use DataTable.
The input and output variables in the code below (first and last lines), are the wrappers for the actual BP collections in the BP object.
DataTable localList = input;
DataTable localOutput = new DataTable();
DataRow[] rows = localList.Select();
while (localList != null)
{
for (int i = 0; i < rows.Length; i++)
{
string indexValue = Convert.ToString(localList.Rows[i]);
//example Regex
string sPattern1 = "[0-9]{5,8}[A-Z][A-Z]";
Match match1 = Regex.Match(indexValue, sPattern1);
///same thing with sPattern2, 3, 4, 5 & 6... with corresponding match2, 3, etc...
if (match1.Success || match2.Success || match3.Success || match4.Success ||
match5.Success || match6.Success)
{
localOutput.NewRow();
localOutput.Rows.Add(indexValue);
}
else
{
localOutput.NewRow();
localOutput.Rows.Add("Not Found");
}
}
}
output = localOutput.Select();
So, this code compiles OK, i.e. doesn't throw any type-cast errors or anything like when I tried to use List<>, but then when I run the object BP throws the following runtime exception:
Internal : Could not execute code stage because exception thrown by code stage: Input array is longer than the number of columns in this table.
What am I doing wrong? I'd appreciate any help with this, thank you.
First, you have to define the columns:
DataTable localOutput = new DataTable();
localOutput.Columns.Add("Column1", typeof (string));
Then you can add new rows.