Where do you use script parameter?
PSOS don't have same session as client, you need to remake found set (your case seems need only current record).
Try using Get(ScriptParameter) on line 6.
Changing layouts does not kill the global variables.
To troubleshoot this: trap for errors on the important steps and have the script report back where it is and what error occurred ifi any.
The issue seems to be line 30. Works well on LAN but no over the WAN. The global variable is working fine without errors...