21-03-23 09:29 AM
Hi Team,
I need some sort of help to understand how to achieve this in code
Suppose a i have a collection with fieldname Doc# which has 3 rows 1145202, 1005203, 1145204
I need to get the row which has highest last 2 digit in Doc# column. Can we do this via Sort/Filter collection or any other approach?
Regards
Rohan
21-03-23 10:19 AM
Hi Rohan
This can be achieved by Linq in code stage
Use the below code
OutColl = (From row in InColl.AsEnumerable() _
Order By Cint((row(FieldName)).Substring(row(FieldName).Length-2)) Descending Select row).CopyToDataTable
OutColl is output Colletion , InColl is input collection , FieldName is column name in which the sorting should be done this build for descending based on last two digits
if you think to make it more dynamic you can use variable for order and digits length
Hope this is what you expected result
Also refer to https://community.blueprism.com/communities/community-home/digestviewer/viewthread?MessageKey=99472cf6-1d84-4d4b-9fc7-12186ba65599&CommunityKey=3743dbaa-6766-4a4d-b7ed-9a98b6b1dd01#bm99472cf6-1d84-4d4... thread for detailed steps of building
Regards
21-03-23 10:59 AM
Attaching object with little more dynamic
Please let me know if this is working for you
Regards
21-03-23 01:48 PM
Thanks for the Solution it is working fine. Is there any way we can do it through process? by not creating a object?
21-03-23 02:22 PM
if you want to do without code stage then check this solution
Add one more column the collection using utility - collection manipulation (Append Field)
loop through the collection , use calculation stage (Right function) to set last two digits to added column
Once loop is completed - sort the collection with Sort collection action of utility - collection manipulation
Hope this helps you
Regards
21-03-23 02:40 PM
Thanks for the Input at quick time. Doing in the same way.
Regards
Rohan