Accessing List Index from Script?

How can I access the index of an item in a list view? I have a button in my list row, and I'm simply trying to log the index of this button to the console. Everywhere I've read says to use the "magic i" variable but in my run script action it says "i" is undefined.

This community post may be helpful -- https://community.retool.com/t/how-to-access-index-in-a-listview/12370/3

I believe this set up should work! The linter will warn that the i variable is undefined because it doesn't get defined until you click the button in the list