85
Views
3
Comments
Solved
Spot the difference: Index Out of Bounds Error on ListRemove Action
Application Type
Reactive
Service Studio Version
11.53.43 (Build 62091)

Hello. I'm unexpectedly getting an Index Out of Bounds Error on a ListRemove action. 

Here are screenshots of my setup - (sorry, cannot share OML due to NDA):

2 tables: "I" and "S"; each table is populated by a List local variable:  "I-List" and  "S-List" 


Each var is populated by a ListAppend Action: 



Here are the tables summarizing the variables: 

Here are the actions allowing a user to delete a record row in each respective table on double click of the trash icon in the row: 

I am only getting an Index out of bounds error when user deletes a value from the "S-table". This error appears regardless of which row the user is deleting from the table or how many records are in it.


 

There is only one difference I am aware of between the two variables: The I-List variable isn't exclusively populated by the I-Append action. There are other actions that feed rows to the list. The S-List variable is solely populated by that one S-Append action. 

Can anyone figure out what is producing the Index Out of Bounds error? I thought the error indicates at runtime that you have an empty list. But the presence of rows on the S- table shows that the list isn't empty.

I'd appreciate your extra eyes on this. Thanks!

I and S - sameLists - only-one-error.pdf
2023-04-16 15-25-31
Krishnanand Pathak
Solution

Hi @Mylah de la Rosa ,

As per the information provided it looks fine.
Try to debug the S-Remove action(which generates error) and check the value of CurrentRowNumber and also check the list(Does it contains the record on that Index) as shown below.





Regards
Krishnanand Pathak

2024-09-12 02-43-38
Deepsagar Dubey

Hi @Mylah de la Rosa 

You can get the index at runtime and then use the listRemove action and pass the index which you got from listIndexOf action,

You can use listIndexOf action then pass the index value in listRemove, but make sure the index is greater than -1,

Because if you got index then it's guaranteed that you have element at that specific index in list 

I hope It'll help to solve your issue,

Thanks

Deep

UserImage.jpg
flowcooker

Thank you! 

@Krishnanand Pathak your suggestion to use the debugger prompted me to try out the Debugger for the first time (I'm new to Outsystems.) It didn't take long for me to see that I had been pointing the "S-list" trash icon to the "I-RemoveAction". I corrected the handler and it now works. Thank you so much. :D

@Deepsagar Dubey, thank you so much. Yours was all very helpful information too. I'll remember the listIndexOf action for future usages. 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.