Thank you for your post.
A video would definitely be helpful. I have sent you a private message with instructions where to send the file.
From your description, I am unable to determine if the issue is with Go To Related Record puts focus on the wrong record, or if the other script steps are failing.
I realize the issue is hard to reproduce, so the next time the prescription is printed with the wrong name, let me know if the wrong name record is one of the records in the found portal set. If so, notice if it is next to the related record, first, or last. Any other observations could be helpful.
Sorry for the long delay, but the issue has been elusive and I havent been able to capture it on video. I am giving up on a solution for this as I am trying to move clients over to 15 to avoid the multitude of issues still present in 14, sorry to say.
As a remedy for this issue, I have installed a control mechanism to check if we really are on the right record before printing the prescription. If not, the user is given a notification that an error occured and that the application must close.
Edit: I just had a hunch that this issue probably is related to the timing issue that has been reported earlier with server 14v4. This client is still on server version 14.v4 as it is a shared server and never will be upgraded to 15 because of the new license policy.