11 Replies Latest reply on Nov 14, 2012 6:58 AM by farview

    Passing field values as a parameter between FMP files on the server

    farview

      We are using FileMaker Server 12.0.2.232.

       

      We have file-a and file-b.

       

      In file-a we have a field named: file-a::name. We also have a script in file-a named call-file-b-script.

       

      In file-b we have a script named file-b-script.

       

      In call-file-b-script we have the script step: Perfomr Script ["file-b-script" from file: "file-b"; Parameter: file-a::name]

       

      The problem: When the script is called from a client connected to the server it passes the value correctly but when it is called from the server as a schedule it passes an empty string.

       

      Note: Both files have no password and use the same user. file-a has file-b as an external data source.

       

      What is the difference between the client and the server execution in this situation and what should we do differntly on the server to make this work.

       

      Thanks,

       

      Arie

        • 1. Re: Passing field values as a parameter between FMP files on the server
          mikebeargie

          Hi Arie,

           

          You are running two different contexts here. As a user logged into a client, you have already opened file-a, gone to a record, and then executed your script. This has a context to grab your script parameter from.

           

          What I would recommend is creating a separate server side script based on your file-b script, in file-b, that opens file-a, finds a specific value, sets that value as a variable, and then goes back to file-b to perform the rest of the script.

           

          So it would look something like (this is from file-b)

           

          -Open file-a

          -GoTo Layout (layout your data is on)

          -GoTo Record (record you are looking for value from)

          -Set Variable $param = (field you are pulling data from).

          -Close file-a

          ----continue with file-b script----

           

          Using that, you would just need to replace get(scriptParameter) with $param anywhere it's used in the file-b script, and you would then have the correct context for running as a server scheduled script.

          • 2. Re: Passing field values as a parameter between FMP files on the server
            farview

            Mike

             

            We would have done that and it is a good solution but we do not want file-b to relate (know about) to file-a. We are actualing accessing file-b from multiple files with the same method.

             

            Arie.

            • 3. Re: Passing field values as a parameter between FMP files on the server
              mikebeargie

              my method does not require file-a to be related in any way. It just requires that you know what you're looking for in file-a from the context of file-b so that you can script it that way.

              • 4. Re: Passing field values as a parameter between FMP files on the server
                wimdecorte

                Mike Beargie wrote:

                 

                 

                 

                -Open file-a

                -GoTo Layout (layout your data is on)

                -GoTo Record (record you are looking for value from)

                -Set Variable $param = (field you are pulling data from).

                -Close file-a

                ----continue with file-b script----

                 

                Using that, you would just need to replace get(scriptParameter) with $param anywhere it's used in the file-b script, and you would then have the correct context for running as a server scheduled script.

                 

                I don't see how this would work.  A local variable ($param) dies when the script ends.  That's the scope of a local variable.  A global variable ($$param) wouldn't work either because the scope there is the file.  As soon as you close file-a all variables are gone.

                • 5. Re: Passing field values as a parameter between FMP files on the server
                  beverly

                  What is the PATH to the file "b" (as seen in Manage External Data Sources in file "a")? if they are on the same server, are they in the same FOLDER/directory? does the path start with "file:" or "fmnet:"? or something else?

                   

                  Beverly

                  • 6. Re: Passing field values as a parameter between FMP files on the server
                    farview

                    Beverly

                     

                    The path starts with file: and both files are in the same directory on the server.


                    Arie.

                     

                    Beverly Voth wrote:

                     

                    What is the PATH to the file "b" (as seen in Manage External Data Sources in file "a")? if they are on the same server, are they in the same FOLDER/directory? does the path start with "file:" or "fmnet:"? or something else?

                     

                    Beverly

                    • 7. Re: Passing field values as a parameter between FMP files on the server
                      mikebeargie

                      What if you passed the script result from a sub-script in file-a, back up to the wrapped script in file-b?

                       

                      IE from file-b:

                      run script - file-a subscript

                      set variable $result - get result from above script.

                      do file-b stuff...

                       

                      I was under the impression that variables were session/script based, and would work if you did all of the above inside of the same script in file-b.

                      • 8. Re: Passing field values as a parameter between FMP files on the server
                        farview

                        Mike

                         

                        In order to do that file-b will have to know about file-a, i.e. have a hard wired external data source to file-a. We want to implement the script in file-b as an API, so every external file can connect and call the script in file-b.

                         

                        Arie.

                        • 9. Re: Passing field values as a parameter between FMP files on the server
                          Mike_Mitchell

                          What about setting a field in file b from file a (either a global or a field in a one-record table via a relationship), then using that as your script parameter?

                           

                          Mike

                          • 10. Re: Passing field values as a parameter between FMP files on the server
                            BowdenData

                            Arie,

                             

                            Have a look at the BaseElements plugin. It has a function (BE_ExecuteScript) to call a script in another file and I don't think that it requires any FileMaker external data source to be defined. Note in the function description though that it is a one-way street - no results are set or data returned via the plugin call.

                             

                            https://github.com/nickorr/BaseElements-Plugin/wiki/Functions#wiki-BE_ExecuteScript

                             

                            There may be other plugins that can do this was well such as Scriptmaster or perhaps Troi File. I don't know for sure, so just guessing here.

                             

                            HTH.

                             

                            Doug

                            • 11. Re: Passing field values as a parameter between FMP files on the server
                              farview

                              The reason for posting this discussion was mostly to get an answer for the reason that his code behaves differently on the server then on the client. There is nowhere in the FileMaker documentation or any reference that we found that leads us to believe that this combination should behave differently yet it does not work on the server.

                               

                              We do have solutions, such as placing the value directly in file-b then calling the script without the parameter but the script parameter is the most elegant and correct way to do what we want.

                               

                              Perhaps we should conclude that this might be a bug in FSM 12. We have not tested this particular code with server 11.

                               

                              Arie.

                              farview wrote:

                               

                              We are using FileMaker Server 12.0.2.232.

                               

                              We have file-a and file-b.

                               

                              In file-a we have a field named: file-a::name. We also have a script in file-a named call-file-b-script.

                               

                              In file-b we have a script named file-b-script.

                               

                              In call-file-b-script we have the script step: Perfomr Script ["file-b-script" from file: "file-b"; Parameter: file-a::name]

                               

                              The problem: When the script is called from a client connected to the server it passes the value correctly but when it is called from the server as a schedule it passes an empty string.

                               

                              Note: Both files have no password and use the same user. file-a has file-b as an external data source.

                               

                              What is the difference between the client and the server execution in this situation and what should we do differntly on the server to make this work.

                               

                              Thanks,

                               

                              Arie