Blue Prism : Find Any Value inside a collection to return row and column Index

This VBO will find any value inside a collection and return the Column Name, Row Index and Column Index.

It will also list down all the occurrence of the keyword inside the collection with it’s column name, row index and column index.

Example: If a Collection has Columns named as “Name”, “Age” and “Sex” , and it has multiple rows, You want the find the value “Vivek”, but you don’t know where is it present or which column it may be present, just use this VBO and it will give you an output in the below format.

Column Name, rowindex, columnindex

Name, 1,1

Name,4,1

Which translates into the keyword “Vivek” being present in column named as  “Name” and is present in 1st row of 1st column and is also present in 4th row of 1st column.

 

Download Link:  


Input: Collection , Keyword

Output: A Collection which contains all occurrence details.

Code:

DT = new DataTable();
DT.Columns.Add(“Column Name”);
DT.Columns.Add(“RowIndex”);
DT.Columns.Add(“ColumnIndex”);
int rowindex=0;
int columnindex=1;
foreach (DataColumn Column in in_DT.Columns)
{
DataRow[] rows = in_DT.Select(Column.ColumnName+” Like ‘%”+valuetofind+”%'”);
if (rows.Length>0)
{ foreach (DataRow row in rows)
{
rowindex = in_DT.Rows.IndexOf(row)+1;
DataRow dr = DT.NewRow();
dr[“Column Name”]=Column.ColumnName;
dr[“RowIndex”]=rowindex;
dr[“ColumnIndex”]=columnindex;
DT.Rows.Add(dr);
}
}
else
{rowindex = 0;}
columnindex=columnindex+1;
}

 

Happy learning!!!