Using a variable as filter in a table is not working

Hello, im trying to get access to rows in a table, and for that im using the foreach command, and in the filter i use a variable. The problem is that the filter is not working, i tried putting the variable in all of these ways :

  • {index}
  • index
  • index as Integer

and none of these works.

Is there any way to get acces to an specific row in a table but with a variable index? thanks

@egerolamieekoR you cannot use a variable in the filter field.

If it can help in your use case, you can save a particular row of a table to a list variable using a Custom action and then iterate through that list. In this case, you can use a recorder variable to define the row:

@CustomScriptAction(
    input = ['table_values', 'row_counter'],
    output = 'row_value'
)
 
def customScript() {

    def row_value = table_values.getRow(row_counter)
}

Can I use variables, like ${var} in the filter option of the For each loop? If not, how can I do it?

No, you cannot use a variable as a filter.
Perhaps, the workaround above can be helpful.

Okay, thank you

I have used the CustomScriptAction but using a sublist

1 Like

Hi Alesia-san

I would like to use this Custom Action like as “For Each” . My case is that the row_counter counts up from 5 to 7 dynamically in the loop. And I want to get the row_value from the table_values by each row_counter. So I would like to know contents of the row_value in above case.

-The table_values is [‘one’, ‘two’, ‘three’, ‘four’, ‘five’, ‘six’, ‘seven’, ‘eight’]
-The row_counter counted up from 5 to 7 in the loop.
-When got the row_value from table_value by each row_counter in the loop, is the contents of row_value changing from [‘five’] to [‘seven’] sequentially?

Please let me know. Many thanks.
Best regards,
Shigeki Hagiwara

Sure, if the Custom script is in a loop, it receives the value in “row_counter” dynamically, so it changes in each loop.

1 Like

Alesia-san

Thank you for your early response. Your reply is very helpful. Many thanks !
I hope that the filter field will be capable to use variables in RPAe so that we can get the values from the table dynamically.

Best regards,
Shigeki Hagiwara

1 Like

There is a voting topic for this feature.

Please vote for it to raise its priority. Currently, it has only 5 votes.

1 Like