Get ( ActivePortalRowNumber )
And be careful if you have more than one portal on your layout to make sure that the focus is always put on the correct portal.
I try to avoid interacting directly with portals in a script if I can. Instead, I freeze the window, switch to the same set of records on a layout based on the portal's table, do what needs to be done and then switch back.
Thanks...guess I looked in the wrong function reference!