Remove or disable the first two lines of your script and then see if it works.
If your button is located inside the portal row, clicking it puts the focus in that portal row and any references to fields from that portal row record will refer to it, as long as your script(s) do nothing to change the focus on that portal row.
Thus, the first two lines of your script appear unecessary and also lose the focus on the portal row which produces the results you then report here.
removed the first two lines, still same thing.
Is the relationship between portal table occurrence and layout table occurrence a self-join?
If not, then the <current layout> option of the Go to Related Record step is wrong and will a) cause an error and b) leave you on the layout. Then it reads from the first portal.
If you want to read values from the related record that is represented by the portal row, you can just do that, without having to go to a layout. Remove that step; go to portal Row is also unnecessary; at the moment you click that button, you already are there.
Wow I'm a complete idiot. You know how many times I have done this in the past on other solutions. Complete brain fart. That's what It was. Had the wrong table because this was as self join. Thanks Phil