21
Views
9
Solved
###### Compare current id with next id in one table
Question

Hello all,
Can we compare current id with next id in one table??
example i have this list, i want to compare A and B, how to do that?

Thankyou!

Solution

Hi,

You can use CurrentRowNumber to check current and next records.

For current record - GetEmployees.List[GetEmployees.List.CurrentRowNumber].Sample_Employee.Email

For Next record - GetEmployees.List[GetEmployees.List.CurrentRowNumber + 1].Sample_Employee.Email

Thanks

Vinod

MVP

That fails when CurrentRowNumber is already at the maximum, you'll get an index out of bounds error. So you also need to check the list's Length property before doing the check.

Hi Vinod and Kilian,
Thankyou for the respond.. that solved my issue
Thankyou!!
Really appreciated it !

Regards,
Ran

MVP

You're most welcome :). Happy coding!

can i ask another question? if i want to check all, example
first will check A with B, then A with C, next B with A, then B with C and so on..
Can i do that?

MVP

Not as easily, since you have a variable amount of rows to check. What you could do is create a Block that has the list and the current row number as input, does the processing in the preperation, and shows the result. Depending on the size of your list this may be a bit slow though.

Hi Bhetrand,

Do you mean you want to do more sort in case there are same value for a certain field?

Example: Sort by Booking Start, but if same value then Sort by Id.

If it is the case then you can add 2 Sorts: 1 Booking Start and 2 Id (notice the order of sort by).

Something like this

Regards,

Khuong

Hi khuong,