cancel
Showing results for 
Search instead for 
Did you mean: 

Trim all field values in a single row collection

VishveshKadam
Level 2
​Hi Everyone.

Can anyone help me with trimming all field values in a single row collection. I am reading all information on a page into different columns of a collection.
I tried Transpose collection and then delete space action in a loop. But didnt find any way to reverse transpose back to original collection.

The only way I found was to use multi-calculation after at end to trim each value. But I have lot of elements (70+) and wish I could do this lot quicker.
Any suggestion?

Thanks & regards,
Vishvesh

------------------------------
Vishvesh Kadam
Automation Builder
Permanent TSB
------------------------------
2 REPLIES 2

AndreyKudinov
Level 10

Something like this in C# code stage for any number of columns/rows, needs System.Data.DataSetExtensions.dll reference:

foreach (DataColumn column in inCollection.Columns){
	if (column.DataType == typeof(string)) {
		for (int i = 0; i < inCollection.Rows.Count;i++) {
			inCollection.Rows[i][column.ColumnName] = inCollection.Rows[i].Field<string>(column.ColumnName).Trim();
		}
	}
}

outCollection = inCollection;

p.s. You might need to additionally check for DBNull if inCollection comes from some other code in the same code block (database query for example), but Blueprism collections should not ever have DBNulls in them and this should not be a concern here.

------------------------------
Andrey Kudinov
Project Manager
MobileTelesystems PJSC
Europe/Moscow
------------------------------

Thanks a lot Andrey Sir.

It worked perfectly as i wished for.

Cheers,
Vishvesh​

------------------------------
Vishvesh Kadam
Automation Builder
Permanent TSB
------------------------------