Retrieve Row Number

Retrieve Row Number

  

Hi all! I'm looking for a way to get the row number of a specific record in a list. It just occurred to me that one way to do this is by looping through the list (using For Each), set a condition for the desired record, and then store the current row number. Is there a better way to do this (like perhaps a system function I don't know about)? Thanks!

Juan Reyes wrote:

Hi all! I'm looking for a way to get the row number of a specific record in a list. It just occurred to me that one way to do this is by looping through the list (using For Each), set a condition for the desired record, and then store the current row number. Is there a better way to do this (like perhaps a system function I don't know about)? Thanks!

Hello Juan,

You can use something like that:

Ticket.List[5].Text.Value

In this case I'm pointing to row 5.


Hope this helps,

Regards,

Cristiano

There are several list functions available, for example listindex will return the (first) index of the item which matches your expression, or -1 if there is no match.

Listfilter will return a list of items which match the given expression.

Solution

Hi Juan Reyes,

1) If you want to get the RowNumber for the selected row in List Records or Table Records widget (Grid) you can retrieve the row number from CurrentRowNumber property i.e. you can assign an On Click action input parameter with the widget CurrentRowNumber property.

2) You can use the System action called ListIndexOf which will give you the position of the desired record as per the conditional check on each of the list element. 

Limitation: It will only give the position of the first element found in the list which satisfies the condition and the position for the rest list record which satisfies the condition will not be available.

3) If you want to have all the list record RowNumber which satisfies the search condition for desired record, I think you have to iterate the list record using the for each loop.


Kind Regards,

Benjith Sam

Solution

Just an observation.

Whenever you click in a line of a Table/List Records, the Table/List Records List.Current become that line, and the List.CurrentRowNumber become the Row number of that line.

You have access to those values inside a screen action called from this click. No need to pass it as InputParameter.

So, if you want the Current Row Number of a line you clicked in, inside a Screen Action, you can just use it.
If you want the index of an element in a generic list in logic, you can use ListIndex, as it was stated more than once before. Here you have a "list" of "list functions" ;)
https://success.outsystems.com/Documentation/10/Reference/Data/Data_Types/List

Cheers.

Hi Christiano,

The method you are referring to is the other way around.
It adds to the topic so you have my like.

Cristiano Chamorra wrote:

Juan Reyes wrote:

Hi all! I'm looking for a way to get the row number of a specific record in a list. It just occurred to me that one way to do this is by looping through the list (using For Each), set a condition for the desired record, and then store the current row number. Is there a better way to do this (like perhaps a system function I don't know about)? Thanks!

Hello Juan,

You can use something like that:

Ticket.List[5].Text.Value

In this case I'm pointing to row 5.


Hope this helps,

Regards,

Cristiano