13 Replies Latest reply on Aug 19, 2013 11:51 AM by swillette

    Script won't continue after find in Instant Web Publishing IWP.

    swillette

      Title

      Script won't continue after find in Instant Web Publishing IWP.

      Post

           I have a script that puts the name of a field into a varible, goes to a layout, enters find mode, sets a field with the contents of the varible and then performs find. There is an if statement that if Get(FoundCount) = 0 then go to another layout. 

           The script works perfect in the FileMaker application, but not in Instant Web Publishing IWP. In a web browser, a dialog box pops up letting me know record not found, but then takes me back to the search layout. 

           I want it to go to another layout if the Get(FoundCount) = 0.

           Here is the script:

             
      •           #Searches Dealers/Distributors by name to get Dealer/Distributor ID.
      •      
      •           Set Variable [ $DealerOrderName; Value:Orders::CompanyName ]
      •      
      •           Go to Layout [ “Dealer Distributor” (DealerDistributor) ]
      •      
      •           Enter Find Mode [ ]
      •      
      •           Set Field [ DealerDistributor::CompanyName; $DealerOrderName ]
      •      
      •           Perform Find [ ]
      •      
      •           If [ Get(FoundCount) = 0 //No records found. ]
      •      
      •           Go to Layout [ “Orders Entry” (Orders) ]
      •      
      •           Else If [ Get(FoundCount) > 1 //There are duplicate dealers with this name ]
      •      
      •           Go to Layout [ “Dealer Pick Orders” (DealerDistributor) ]
      •      
      •           Else
      •      
      •           Set Variable [ $DealerID; Value:DealerDistributor::DealerDistributorIDpk ]
      •      
      •           Go to Layout [ “Orders Entry” (Orders) ]
      •      
      •           Set Field [ Orders::DealerDistributorIDfk; $DealerID ]
      •      
      •           End If

             

        • 1. Re: Script won't continue after find in Instant Web Publishing IWP.
          philmodjunk

               You seem to be missing the set error capture step. Wonder which result you are actually getting or if there is an error occuring with the find?

               Is this FileMaker 12?

               Could it be that the layout to which the script is supposed to go is a layout with a theme other than "Classic"?

          • 2. Re: Script won't continue after find in Instant Web Publishing IWP.
            swillette

                 I forgot to include the set error capture step which fixed the problem. I am using FileMaker 12 Advanced and the layout is Classic.

                 I've been working with FileMaker for awhile, and I'm not sure I fully understand the error capture. With this example, why would adding it fix the problem? 

            • 3. Re: Script won't continue after find in Instant Web Publishing IWP.
              philmodjunk

                   Set Error capture [on]

                   Supresses most error dialogs that might otherwise pop up and interrupt the script--such as the no records found or invalid find criteria messages you might get when a script performs a find.

                   I would have thought that you'd get that message even in IWP, but a lot of window and dialog specific script steps are not supported in IWP and this error dialog apparently also fails to show in a web browser even though it interrupts the script.

              • 4. Re: Script won't continue after find in Instant Web Publishing IWP.
                swillette

                     I hate Instant Web Publishing! 

                     Now I have another simple script that works perfect in the Application (FileMaker 12) not working in a web browser. The layout is based on the classic theme. 

                      

                     All this script does is take information that is added / submitted in the browser, copies it and adds it to another table, then copies a serial number then returns to the orginal screen and adds the serial number. Here is the script:

                       
                •           #Copies information from Orders Lookup fields
                •      
                •           #to copy to Dealers/Distributors table.
                •      
                •           Set Error Capture [ On ]
                •      
                •           Set Variable [ $CompanyName; Value:Orders::CompanyName ]
                •      
                •           Set Variable [ $Type; Value:Orders::Type ]
                •      
                •           Set Variable [ $Contact; Value:Orders::Contact ]
                •      
                •           Set Variable [ $Email; Value:Orders::Email ]
                •      
                •           Set Variable [ $Address; Value:Orders::Address ]
                •      
                •           Set Variable [ $City; Value:Orders::City ]
                •      
                •           Set Variable [ $State; Value:Orders::State ]
                •      
                •           Set Variable [ $Zip; Value:Orders::Zip ]
                •      
                •           Set Variable [ $Telephone; Value:Orders::Telephone ]
                •      
                •           Set Variable [ $MobilePhone; Value:Orders::MobilePhone ]
                •      
                •           Set Variable [ $FFLNumber; Value:Orders::FFLNumber ]
                •      
                •           Set Variable [ $FFLExpirationDate; Value:Orders::FFLExperationDate ]
                •      
                •           Set Variable [ $CFDNumber; Value:Orders::CFDNumber ]
                •      
                •           If [ Orders::DealerDistributorIDfk < 1 ]
                •      
                •           Go to Layout [ “DealerDistributor” (DealerDistributor) ]
                •      
                •           Else
                •      
                •           Exit Script [ ]
                •      
                •           End If
                •      
                •           #New Dealer/Distributor is created and
                •      
                •           #information is copied to Dealer/Distributor table.
                •      
                •           New Record/Request
                •      
                •           Set Field [ DealerDistributor::Type; $Type ]
                •      
                •           Set Field [ DealerDistributor::CompanyName; $CompanyName ]
                •      
                •           Set Field [ DealerDistributor::ContactName; $Contact ]
                •      
                •           Set Field [ DealerDistributor::Email; $Email ]
                •      
                •           Set Field [ DealerDistributor::Address; $Address ]
                •      
                •           Set Field [ DealerDistributor::City; $City ]
                •      
                •           Set Field [ DealerDistributor::State; $State ]
                •      
                •           Set Field [ DealerDistributor::Zip; $Zip ]
                •      
                •           Set Field [ DealerDistributor::Telephone; $Telephone ]
                •      
                •           Set Field [ DealerDistributor::MobilePhone; $MobilePhone ]
                •      
                •           Set Field [ DealerDistributor::FFLNumber; $FFLNumber ]
                •      
                •           Set Field [ DealerDistributor::FFLExpirationDate; $FFLExpirationDate ]
                •      
                •           Set Field [ DealerDistributor::CFDNumber; $CFDNumber ]
                •      
                •           #Copies newly created Dealer/Distributor ID to paste in Order.
                •      
                •           Set Variable [ $DealerID; Value:DealerDistributor::DealerDistributorIDpk ]
                •      
                •           Go to Layout [ “Orders Entry” (Orders) ]
                •      
                •           #Adds newly created Dealer/Distributor ID to Order.
                •      
                •           Set Field [ Orders::DealerDistributorIDfk; $DealerID ]
                • 5. Re: Script won't continue after find in Instant Web Publishing IWP.
                  philmodjunk

                       Designing for IWP can feel a bit like trying to tap dance in a phone booth. wink

                       I don't see any web incompatible script steps here. (You do know how to check for that don't you?)

                       How is this script performed? By clicking a button or tripping a script trigger? Users cannot directly trip script triggers when accessing your database from a web browser of if you are expecting a script trigger to perform this script, that isn't likely to happen for IWP users.

                  • 6. Re: Script won't continue after find in Instant Web Publishing IWP.
                    philmodjunk

                         Think I just saw what's the issue. Try adding Commit Records as your final script step. I suspect that has to happen before the assigned fk value produces the desired update on your screen...

                    • 7. Re: Script won't continue after find in Instant Web Publishing IWP.
                      swillette

                           I agree the script looks normal and OK to work in IWP. 

                           The script is on an underlined word Add, next to the Dealer Name Field  title. The user would have to click on the word Add to add the new dealer.

                           I tried adding Commit Records but that didn't work. It still works great in the FileMaker Application.  

                      • 8. Re: Script won't continue after find in Instant Web Publishing IWP.
                        philmodjunk

                             Exactly how does it "not work"?

                        • 9. Re: Script won't continue after find in Instant Web Publishing IWP.
                          swillette

                               The browser window "blinks" and then does nothing. 

                               I have the same script on another layout that does the same exact thing and works perfect. 

                               It's not the layout because I tested it on a dialog box type layout and it does'nt work from a OK button on that layout.

                               Here is the add customer script that is the same as the add dealers. 

                                 
                          •           

                                           #Copies information from Repairs Lookup fields

                                 
                          •      
                          •           

                                           #to copy to Dealers/Customers table.

                                 
                          •      
                          •           

                                           Set Error Capture [ On ]

                                 
                          •      
                          •           

                                           Set Variable [ $NewCustName; Value:Repairs::CustomerName ]

                                 
                          •      
                          •           

                                           Set Variable [ $NewCustEmail; Value:Repairs::CustomerEmail ]

                                 
                          •      
                          •           

                                           Set Variable [ $NewCustAddress; Value:Repairs::CustomerAddress ]

                                 
                          •      
                          •           

                                           Set Variable [ $NewCustCity; Value:Repairs::CustomerCity ]

                                 
                          •      
                          •           

                                           Set Variable [ $NewCustState; Value:Repairs::CustomerState ]

                                 
                          •      
                          •           

                                           Set Variable [ $NewCustZip; Value:Repairs::CustomerZip ]

                                 
                          •      
                          •           

                                           Set Variable [ $NewCustPhone; Value:Repairs::CustomerTelephone ]

                                 
                          •      
                          •           

                                           Set Variable [ $FirearmSerial; Value:Repairs::SerialNumberIDfk ]

                                 
                          •      
                          •           

                                           If [ Repairs::CustomerIDfk < 1 ]

                                 
                          •      
                          •           

                                           Go to Layout [ “Customer” (Customer) ]

                                 
                          •      
                          •           

                                           Else

                                 
                          •      
                          •           

                                           Exit Script [ ]

                                 
                          •      
                          •           

                                           End If

                                 
                          •      
                          •           

                                           #New Customer is created and

                                 
                          •      
                          •           

                                           #information is copied to Customer table.

                                 
                          •      
                          •           

                                           New Record/Request

                                 
                          •      
                          •           

                                           Set Field [ Customer::Name; $NewCustName ]

                                 
                          •      
                          •           

                                           Set Field [ Customer::Email; $NewCustEmail ]

                                 
                          •      
                          •           

                                           Set Field [ Customer::Address; $NewCustAddress ]

                                 
                          •      
                          •           

                                           Set Field [ Customer::City; $NewCustCity ]

                                 
                          •      
                          •           

                                           Set Field [ Customer::State; $NewCustState ]

                                 
                          •      
                          •           

                                           Set Field [ Customer::Zip; $NewCustZip ]

                                 
                          •      
                          •           

                                           Set Field [ Customer::Telephone; $NewCustPhone ]

                                 
                          •      
                          •           

                                           Set Field [ Customer::SerialNumberfk; $FirearmSerial ]

                                 
                          •      
                          •           

                                           #Copies newly created Customer ID to paste in Repair.

                                 
                          •      
                          •           

                                           Set Variable [ $CustomerID; Value:Customer::CustomerIDpk ]

                                 
                          •      
                          •           

                                           Go to Layout [ “Repairs” (Repairs) ]

                                 
                          •      
                          •           

                                           #Adds newly created Customer ID to Repair.

                                 
                          •      
                          •           

                                           Set Field [ Repairs::CustomerIDfk; $CustomerID ]

                                 
                          •      
                          •           

                                           Commit Records/Requests [ No dialog ]   

                                 
                          • 10. Re: Script won't continue after find in Instant Web Publishing IWP.
                            philmodjunk

                                 Have you confirmed that it "does nothing" in terms of data in your tables?

                                 Have you checked to see if a new record was created in the customer table? (Even though all fields may not be correctly populated with data.)

                                 You might try defining a global field and then adding a series of set field steps to set data such as "Step 1" , "Step 2" and so forth. THen you place that global field on your web browser layout, perform the script and watch to see if the value in the global field changes and if it does, what value is the last value set to it. That might narrow this down to a particular section of your script or tell us that the script is not being performed at all.

                                 You might also enable the script debugger and run this script from FileMaker Advanced to see if any other scripts pop up and execute in the middle of this script. That will happen if your script trips any script triggers, such as by changing layouts. If that script is not web compatible, it might bring this to a screeching halt and your script then fails to run to completion.

                            • 11. Re: Script won't continue after find in Instant Web Publishing IWP.
                              swillette

                                   The script was updating another layout tied to the same table that I incorrectly put in the script because the layout name was almost exactly like the layout I wanted updated. 

                                   I don't know why that would matter in IWP, because it was not a problem in the FM application. 

                                   Once I changed the name in the script, it worked in IWP!

                                   Your trouble-shooting suggestion are great, and they helped me see the problem in database. Thank you!

                              • 12. Re: Script won't continue after find in Instant Web Publishing IWP.
                                philmodjunk

                                     "Another layout tied to the same table" should either have produced the same problem whether or not you were in IWP or should have been no problem at all.

                                • 13. Re: Script won't continue after find in Instant Web Publishing IWP.
                                  swillette

                                       So you forced me to dig deeper and I'm glad you did.

                                       The layout it was going to was not in the layout list so I thought that was the problem. 

                                       That wasn't the problem, but that layout was not based on the Classic theme. So the script was going to the wrong layout that was not based on Classic. This is where it was erroring out in IWP.

                                       The script debugger did not error out, but it revealed to me that the script was going to the wrong layout.