I have a very simple script
Go to Layout
Find a set of records
Replace field contents of a related field with a
This works fine when run.
But when I PSOS it does not run.
Treat PSoS as a user signing in. You need to make sure you're in the right context and you'll probably want to trap to see if the script is running in Pro or on Server in your OnFirstWindowOpen script. If you're running on Server you may be able to avoid most of the stuff in the OFWO script. In the Script Workspace you can also set the window to display what is compatible in a PSoS script - you might be doing something that requires user interaction - like the Replace command. Check for a "With Dialog: ON" in the Replace step.
Replacing a field in a related record may cause performance issues. Do your find and then go to related records matching the found set, then do the replace there.
everything David said AND make sure the server account has the right permissions...
You should also be aware that PSOS replace is the same as client replace in that it does not fail gracefully when it encounters a record lock in the found set.
coherntkris and I may spend Christmas Eve going back and forth with additional things you may need to consider.
While we don't know your situation - a graceful fail method may not be needed but is always a good idea. If this is something you want to look into - search for "transactional" in the Community. This is where you'd collect a list of all the pk values of the related records, store them and then process the replace thru a portal (which kind of puts you back where you started). You have to be careful not to commit the records until the end. This way if something fails due to a record lock the entire set reverts - helping to maintain data integrity; you don't end up with a partially update set of records. You get the entire set or none of it updated.
If possible in your situation - this could also be something that you may be able to process "off-hours" as a server-based script. Again, it depends on your application.
This will be a script that the server will run at 1am every night.
When I changed it from Replace to Loop it worked fine.
When you say "Make sure server has correct permissions" I assumed the server had full access. How do I check that?
You entered account/password for running the script when you made schedule. Dialog for selecting database would show it.
Retrieving data ...