6 Replies Latest reply on Jul 23, 2014 8:08 AM by AustinCarr

    Go To Record/Request/Page [problem]

    AustinCarr

      Title

      Go To Record/Request/Page [problem]

      Post

           i'll keep this short. In my script I perform a find that uses set variables from a different layout(lOriginal)  and switches layouts (Layout2) to perform the find and then switches back to (Orginal layout) to display the results. My problem is if there is a matching record ...when the script switches back to the original layout instead of going back to the record we were just on, it goes to the matching records information. I thought using Go to Record/Request/Page [previous] would fix this but it only seems to go to a previous record on the list and not the previous record just visited. Script looks something like this in an If loop:

           

                If there is a match:

           

                Go to layout [ Original (_table1)]

           

                Go to Record/Request/Page [Previous]

           

                Show Custom Dialog

           

                Halt Script

           Any advice would be appreciated, Thanks

           -Austin

        • 1. Re: Go To Record/Request/Page [problem]
          philmodjunk

               If both layouts are based on the same Table Occurrence (box found in Manage | Database | Relationships) by selecting the same name in Layout Setup...|Show Records from, then both layouts share the same found set if displayed in the same window.

               That then identifies two alternative approaches to keeping your current record, found set and sort order unchanged in the first layout:

               1) Set up the second layout to be based on a different table occurrence

               2) Ope a new window. Perform the search there and then close the window to return to the original layout.

               For more on table occurrences, see: Tutorial: What are Table Occurrences?

          • 2. Re: Go To Record/Request/Page [problem]
            AustinCarr

                 I set my script up so that it look like this, funny thing happened, my results reversed! Now whenever there is a match it switches to original layout and if there isn't a match it tells me there is a duplicate! Is the "Window" script set up properly?

                 

                      Set Variables [  ]

                 

            New Window [Style: Document]

                 

                      Go to Layout [Layout 2]

                 

                      Enter Find Mode []

                 

                      Set Field

                 

                      Set Field

                 

                      Perform Find []

                 

            Close Window [Current Window]

                 

                      If matching statement

                  

            • 3. Re: Go To Record/Request/Page [problem]
              philmodjunk

                   I suggest posting the actual scripts instead of an outline. Nothing in your outline should create a new record let alone a record with a duplicate value.

                   To post a script to the forum:

                     
              1.           You can upload a screen shot of your script by using the Upload an Image controls located just below Post a New Answer.
              2.      
              3.           You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here. (with this approach, you can get multiple script steps on the same line, please edit the pasted text by inserting some returns to separate those steps.)
              4.      
              5.           If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
              6.      
              7.           If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format.
              • 4. Re: Go To Record/Request/Page [problem]
                AustinCarr
                     Sorry for the pseudocode earlier I am fairly new to filemaker! Some more information: Invoices has a relationship with Trans. Trans has a relationship with our Products table (Lists all our products). Script starts on layout StoreForm (Invoice)
                      
                     

                          Commit Records/Requests [Skip data entry validation; No Dialog; Force Commit]

                     

                          Set Variable [$ItemNumber; Value:Invoice::Item#]

                     

                          Set Variable [$StoreItem; Value:StoreOrders::Item]

                     

                          Set Variable [$Yes; Value:"Yes"]

                     

                          New Window [Style: Document]

                     

                          Go to Layout ["StoreOrders"  (Invoice)]

                     

                          Enter Find Mode [ ]

                     

                          Set Field [Trans::Item; Trans::Item]

                     

                          Set Field [Trans::Item#; "==" & $ItemNumber]

                     

                          Set Field [Invoice::Saved; "Yes]

                     

                          Perform Find [ ]

                     

                          Close Window [Current Window]

                     

                          If [Get (LastError) = 401]

                     

                    Go to Layout ["StoreForm" (Invoice) ]

                     

                    Go to Record/Request/Page [Last]

                     

                    Show Custom Dialog ["No Duplicates"; "NO RECORD FOUND"]

                     

                          Else

                     

                    Go to Layout ["StoreForm" (Invoice) ]

                     

                    Go to Record/Request/Page [Last]

                     

                    Show Custom Dialog ["No Duplicates"; "NO RECORD FOUND"]

                     

                    Halt Script

                     

                          End If

                     

                          Exit Script [ ]

                      

                     PS- Thanks for the link for Known Bugs List database! Great find!

                • 5. Re: Go To Record/Request/Page [problem]
                  philmodjunk

                       Invoices---<Trans>----Products

                       When using if [ Get ( LastError ) ]

                       it must come immediately after the script step that might generate the error code. Thus, you can't put Close Window between it and Perform find.

                       But your script also displays the same message in the dialog whether an error code is returned or not. You have two identical messages in show custom dialog steps in both parts of if block.

                       To fix the error message, you can do one of two things:

                       Perform Find[]
                       Set Variable [$Err ; value: Get (lasterror ) ]
                       Close window
                       If [ $Err = 401 ]

                       or

                       Perform Find []
                       If [ Get (LastError ) = 401 ]
                          Close Window
                          and so forth
                       Else
                          Close Window
                          and so forth
                       End IF

                       but you'll still get the same message popping up until you change the show custom dialog message inside the Else part of the If block.

                       And there are simpler ways to check and see if the same item was ordered previously on an invoice than by using a scripted find. You can also use a relationship from Invoices::ItemNumber to a different occurrence of invoices and trnasactions that matches by item number and "yes" to make the same check without performing a find.

                  • 6. Re: Go To Record/Request/Page [problem]
                    AustinCarr

                         Rookie mistake must've happened when I was copying and pasting the code over to you. It works great. Thanks for your help man