7 Replies Latest reply on Dec 17, 2015 3:41 PM by tkessler45

    Script not performing on server...

    tkessler45

      In my table I have a field called "GlobalTest" that holds text, and I've got one script that is started by a button on a layout in FileMaker Go:

       

      ...

      (Some Script Steps...)

      Set Field [ AuditTable::GlobalTest ; "StartServer" ]

      Perform Script on Server [ Wait for completion ; "ServerScript" ]

       

      For the server script, the following is to happen (the find request locates a single record by a unique number):

       

      Go to Layout [ "AuditLayout" (AuditTable) ]

      Perform Find [ Restore ]

      Set Field [ AuditTable::GlobalTest ; "FromServer" ]

       

      With this, I would expect the GlobalTest field value to be "FromServer" by the server when the second script is triggered from the first; however, it doesn't happen. The first seems to work, and the GlobalTest value ends up as "StartServer" but the second does not work. I've tried adding a "Commit Records" step after setting the field, but it doesnt work either.

       

      Message was edited by: Topher Kessler Typo...changed "Set Find" to "Set Field"

        • 1. Re: Script not performing on server...
          coherentkris

          when you run a script on server it runs as its own isolated process/session.

          Invoking variables or setting global fields in a script run on server are known within the session only.

          It's as if you had user A set a global field to value 45.

          If you were user B looking at the same global field you would not expect to see 45 unless you set it to 45.

          • 2. Re: Script not performing on server...
            tkessler45

            The GlobalTest field was a global variable, but I changed it to not be so, and it still does not work.

            • 3. Re: Script not performing on server...
              TSPigeon

              tkessler45:


              Thank you for your post.


              I believe your issue has to do with the fact the "Perform Script on Server" is going to start a new session on FileMaker Server, which would not have access to your FileMaker Pro Session's Global Values.

               

              "Server-side FileMaker scripts run in separate sessions..." "Each session has its own copy of global fields and variables..."

               

              You might check Running FileMaker Scripts for more information on this.


              I hope this information helps!


              TSPigeon

              FileMaker, Inc.

              • 4. Re: Script not performing on server...
                coherentkris

                info on globals and server

                General information about the Perform Script On Server script step | FileMaker

                 

                (Some Script Steps...)

                Set Field [ AuditTable::GlobalTest ; "StartServer" ]

                >>server session will not have any ability to access this global

                >> you are now in context A (context is layout/to/table and record)

                Perform Script on Server [ Wait for completion ; "ServerScript" ]

                       >>server does whatever its going to do in its own invisible session now

                       >>goes to context B and does some work.

                Go to Layout [ "AuditLayout" (AuditTable) ]

                Perform Find [ Restore ]

                >> which record does this find? What happens if it finds none?

                Set Field [ AuditTable::GlobalTest ; "FromServer" ]

                >>Server side script exits and server session is gone.

                >> you now return to exact context A. If context A is the same as Context B then you should see your last set field

                 

                my guess is that the Perform find changes the record...

                Put a commit right after the set field in the server side script.

                you might want to post the calling script AND the server side script.

                 

                You should also figure out how to pass values out of the server side script with Exit Script (values). Its the only way to see into a server side process.

                • 5. Re: Script not performing on server...
                  coherentkris

                  ya thats what i said

                  • 6. Re: Script not performing on server...
                    tkessler45

                    "GlobalTest" is not a global variable. Despite its name, it is a standard text field in the DB records, just like one would do for "FirstName", "LastName", etc. for a contacts database.

                    • 7. Re: Script not performing on server...
                      tkessler45

                      coherentkris wrote:

                       

                      info on globals and server

                      General information about the Perform Script On Server script step | FileMaker

                       

                      (Some Script Steps...)

                      Set Field [ AuditTable::GlobalTest ; "StartServer" ]

                      >>server session will not have any ability to access this global

                      >> you are now in context A

                      Perform Script on Server [ Wait for completion ; "ServerScript" ]

                             >>server does whatever its going to do in its own invisible session now

                             >>goes to context B and does some work.

                      Go to Layout [ "AuditLayout" (AuditTable) ]

                      Perform Find [ Restore ]

                      >> which record does this find? What happens if it finds none?

                      Set Field [ AuditTable::GlobalTest ; "FromServer" ]

                      >>Server side script exits and server session is gone.

                      >> you now return to context A. If context A is the same as Context B then you should see your last set field

                       

                      For this script, here is what is happening:

                       

                      Set Field [ AuditTable::GlobalTest ; "StartServer" ]

                      >>This is not a global variable, so "StartServer" should be put in the "GlobalTest" field of the current record.

                      Perform Script on Server [ Wait for completion ; "ServerScript" ]

                      >>server does whatever its going to do in its own invisible session now

                       

                      Go to Layout [ "AuditLayout" (AuditTable) ]

                      Perform Find [ Restore ]

                      >> This finds a specific record by its "ID" field which has a value of "Audit." There is only one of these in the entire DB, so it should find this one record.

                      Set Field [ AuditTable::GlobalTest ; "FromServer" ]

                      >> In the single record that was found, this step should set the "GlobalTest" field (not a global variable) to the value "FromServer"...however, it is not doing this.