3 Replies Latest reply on Feb 10, 2016 10:18 AM by siplus

    perform script on server help


      i understand that performing a script on server requires that you treat the script as a new session.   Can anyone give me an example of how I might set up a script that can find a batch of related records in that new session to  set up normal a looping script? 

        • 1. Re: perform script on server help

          perform script on server ("the script")..

          Script Named "the script".....

          -go to find mode

          -set fields

          -perform find


          -do stuff with the found set

          -exit loop if (condition)

          -end loop.

          -exit script(return)

          *** error handling not in the prototype above ***

          What happens in "the script" stays inside the context of the server unless you are setting non global fields in do stuff or you pass results out with exit script(return)

          • 2. Re: perform script on server help

            Just like you would do in a normal user's session...


            If there is something specific in the real user's session that is necessary for the PSoS session then pass it along to the server script as a parameter.

            • 3. Re: perform script on server help

              Perform script on server (PSOS)  is not a swiss knife to all your speed problems. It has to make sense using it. And you have to remember that your database opening script, if any, will be run every time you use PSOS, before the script that you are PSOS'ing.


              Having said that, you can have a script 1:


              Exit Script[ExecuteSQL("SELECT ID from Customers WHERE ZipCode = ?" ;"";""; Get(ScriptParameter) ) ]


              and a script 2:


              Perform Script on Server(script 1) with  parameter: ZIPCode

              Set Variable [  $SameZIPCodeCustomers; Get(ScriptResult)  ]


              at this point you can loop on the values in $SameZIPCodeCustomers, from 1 to ValueCount(), and do things on those customers.