I'm experiencing a very weird issue using Perform Script On Server.
I have a script which at a few points would benefit from offloading some search tasks to the server to prevent thousands of records from being transferred to the client. The server would return a list of IDs.
When I start the script a portal is shown on the screen. The script goes to a utility layout and loops through each record and constructs an SQL query (I've checked and the query that is returned is sound and it runs fine if I run it in Data Viewer) Sometimes I need to perform a logical AND against two sets of record IDs to ensure I only process the records whose IDs appear in both lists; this is another task I'd prefer to perform on the server.
If I use 'Perform Script' everything runs fine.
If I use 'Perform Script On Server', WHEREVER I use it, the next thing that happens is the Search Criteria line items which are shown in the portal, disappear! Deleted! There are no more records in that table. I don't use 'Delete Record' ANYWHERE in any of the scripts and I only go to that layout once when constructing the SQL.
I've attached two screenshots showing the layout before the search is performed (showing the search criteria) and after, then the records have been deleted.
The record deleting happens after any PSOS call so it's not any particular subscript that is causing the issue because the problem goes away if I run that same subscript using 'Perform Script'. In fact running all subscripts by calling Perform Script runs just fine... but very slow!
Also, the main script works correctly so I get the right result (a global field is set to the value of a list of record IDs) and results are shown on screen with the correct record count being shown.
The issue I have is the Search Criteria records are being deleted when they shouldn't be.
Does anyone have any idea how I can troubleshoot this? Maybe this has been an issue for other people???
I appreciate any help or feedback.