6 Replies Latest reply on Dec 20, 2016 4:34 AM by Mike_Mitchell

    OnFirstWindowOpen Script Trigger and CWP PHP Scripts

    fmdataweb

      It was my understanding that all FileMaker clients always triggered the OnFirstWindowOpen script trigger when accessing a FileMaker file, but from some testing today it appears that when you call a script from a PHP page using the FileMaker PHP API it doesn't perform the OnFirstWindowOpen script for the file as part of the process of performing the script.

       

      I've added some logging to my OnFirstWindowOpen script and nothing happens when the PHP page is processed and performs a script using the newPerformScriptCommand method. The specified script is run but the OnFirstWindowOpen script isn't performed.

       

      This isn't necessarily a problem but in my case it's bypassing some setup of global variables that happen when the file is opened - I can easily recreate those in the main script that is being called but first wanted to get some confirmation that PHP scripts called using the newPerformScriptCommand method do not trigger the OnFirstWindowOpen script that is setup in the File menu > File Options? (and presumably also dont' trigger the OnLastWindowClose script trigger).

        • 1. Re: OnFirstWindowOpen Script Trigger and CWP PHP Scripts
          Johan Hedman

          When you use PHP you are asking a specific layout for information, then you do not trigger the OnFirstWindowOpen for the file your are running your PHP-file on

          • 2. Re: OnFirstWindowOpen Script Trigger and CWP PHP Scripts
            fmdataweb

            I would have thought the PHP page needs to authenticate with the FileMaker file, which would include opening the file with the account name/password which would in turn trigger the OnFirstWindowOpen script? In any case I can't seem to get it to run that script so I'm going to have to assume it doesn't run the OnFirstWindowOpen script when performing API requests.

             

             

            The Custom Web Publishing Guide states:

             

            Script triggers and Custom Web Publishing solutions

            In FileMaker Pro, both scripts and user actions (such as the user clicking a field) can activate script triggers. But in Custom Web Publishing, only scripts can activate script triggers. For information on script triggers, see FileMaker Pro Help.

             

            Note To specify that you want a script performed when a file is opened, you need to use the OnFirstWindowOpen script trigger. Similarly, to specify that you want a script performed when a file is closed, you need to use the OnLastWindowClose script trigger.

             

            --

             

            So far I haven't seen any evidence that these are in fact triggered by the PHP page - I've added logging to the top of each of these scripts so that it writes some log records when the scripts are performed, and no records are created when the PHP page is performed. The other actions that the PHP page does are working correctly though.

            • 3. Re: OnFirstWindowOpen Script Trigger and CWP PHP Scripts
              fmdataweb

              The FMP Help lists Custom Web Publishing as supported for the OnFirstWindowOpen script trigger:

               

              FileMaker Pro 15 Help

               

              Would love to hear from anyone out there using CWP as to whether their OnFirstWindowOpen scripts are performed from PHP API pages?

              • 4. Re: OnFirstWindowOpen Script Trigger and CWP PHP Scripts
                Mike_Mitchell

                You missed this phrase in the documentation:

                 

                "But in Custom Web Publishing, only scripts can activate script triggers."

                 

                In other words, opening a window doesn't activate a script, nor does any other event ... because the database is never actually opened. No window opens, no objects are loaded. Therefore, there's no recording of events to trigger the script.

                 

                You can specify a FileMaker script to run as part of the PHP call.

                • 5. Re: OnFirstWindowOpen Script Trigger and CWP PHP Scripts
                  fmdataweb

                  Hi Mike,

                   

                  I did see that reference to "only scripts can active script triggers", but then immediately below that is this text:

                   

                  "Note To specify that you want a script performed when a file is opened, you need to use the OnFirstWindowOpen script trigger. Similarly, to specify that you want a script performed when a file is closed, you need to use the OnLastWindowClose script trigger"

                   

                  I'm assuming as its mentioned in the CWP Guide from FileMaker Inc. that it also applies to CWP, and given CWP is listed as supported for the OnFirstWindowOpen trigger here:

                   

                  OnFirstWindowOpen

                   

                  I'm assuming that it's supported? Unless I'm missing something here why does FileMaker Inc state that it's supported by CWP? What is the trigger for this to run under CWP?

                  • 6. Re: OnFirstWindowOpen Script Trigger and CWP PHP Scripts
                    Mike_Mitchell

                    You're assuming incorrectly. Files do not open, no windows are created, no triggers will file. Reason: No FileMaker client is launched, which is where the triggers happen.

                     

                    I just tested this on a CWP solution. The script doesn't fire.

                     

                    The documentation is a little confusing. I don't know why they say it's supported, because that's just not how it works.

                    1 of 1 people found this helpful