6 Replies Latest reply on Mar 25, 2014 4:15 PM by firebase

    Debuging FM Serverside Scrips

    firebase

      Title

      Debuging FM Serverside Scrips

      Your post

           i am working since about 4 weeks on a few scripts that i now want to move to the server.

           this turns out like a nightmare. as it seams there is no debuging or any kind of view to see what hapends.

            

           right now i am not even able to fill out fields. when i do a set field script in my local fm pro advanced i dont see any information in that one record i use.

            

           what do i have to do to debug and watch what is going on?

            

        • 1. Re: Debuging FM Serverside Scrips
          philmodjunk

               There is no debugging utility available for server side scripts.

               First, review every script step in the scrip editor with"Server" selected in the Show Compatibility drop down in the script editor to make sure that all script steps are server side compatible. Many script steps are not compatible. And some compatible steps have additional limitations or only work with "no dialog" options specified.

               Second, keep in mind that your server side script will not work from the context that you see on the client computer where Perform Script On Server was initiated. It won't necessarily be on the same layout nor the same found set that you see on your client computer. Any key data has to be passed to the script in a script parameter in order for this script to produce the needed "context" before it does the steps you need it to do.

               Third, you can add a table and layout with records that have timestamp and text fields. You can add code to your script that periodically changes over to that layout, creates a new record and records data from key fields/variables into fields in that new record. (You can use set variable to capture the value of a field, change layouts, create the new record and then use set field to transfer the value from the variable to a field in the record.)

               After running the script via perform script on server or a server schedule, you can go to the layout for this table and check to see what data has been logged in records of that table--this is something like using Show Custom Dialog to monitor script execution in a problem script when you don't have FileMaker Advanced.

          • 2. Re: Debuging FM Serverside Scrips
            firebase

                 thanx!

                  

                 first step is clear so far

                 could you maybe give an example on how to set a value into a field from server perspective. because it seams that ii hangs on that issue.

                 i tried to copy values into subfields (lets say debug fields) so i can read which step succeeds, but its not writing anything.

            • 3. Re: Debuging FM Serverside Scrips
              philmodjunk

                   Set field still works in a server side script, but as I pointed out in the second paragraph, your context is completely different from that of the client computer where you used Perform Script on Server to perform the script.

                   Say that you want the server side script to put "George"--text from a global field updated by a user just before performing this script into a field named "firstName" in the "Contacts" Table for the contact record where ContactID = 34--the ID of the current contact record in the client session.

                   You might need to use this parameter expression to send the correct data to your server side script:

                   List ( Globals::gFirstName ; Contacts::__pkContactID )

                   Your server side script might then be:

                   Set Variable [$Name ; value: getValue ( Get ( ScriptParameter ) ; 1 ) ]
                   Set Variable [$ID ; value: getValue ( Get ( ScriptParameter ) ; 2 ) ]
                   Go to Layout ["Contacts" (Contacts ) ]
                   Enter Find Mode []
                   Set field [Contacts::__pkContactID ; $ID ]
                   Perform Find []
                   Set Field [ Contacts::FirstName ; $Name ]

                   Note that the first 6 lines of this script were used just to get to the correct table and record that was the current record in the client session when this script was first performed.

              • 4. Re: Debuging FM Serverside Scrips
                firebase

                     thanx!

                     i could fix the most scripts by adding a got layout abc line.

                     now i got stuck in a regular import .csv script. even the automatic generated import script is not doing anything.

                     i fixed tha path and checked anything else, but no luck.

                     is there a sepcila trick to make that work?

                • 5. Re: Debuging FM Serverside Scrips
                  philmodjunk

                       Import and export records, when done "server side" only work if you stick within very limited options. See this Knowledge Base Article: http://help.filemaker.com/app/answers/detail/a_id/7035/kw/server%20import%20records

                  • 6. Re: Debuging FM Serverside Scrips
                    firebase

                         i found the problem. i read this document before, but i did not realise that "documents" sits inside the filemaker folder itself instead of the win/user/ducuments.

                          

                         si in my case its: filewin:/C:/Program Files/FileMaker/FileMaker Server/Data/Documents/import.csv