5 Replies Latest reply on Sep 14, 2016 8:46 AM by David Moyer

    Get (LastError)

    smfdist

      Using FM15 (on pc)

       

      Problem with this function in a script:

      Table 1 related to Table 2 (1 to many)

       

      Script as follows does NOT work (it always selects as true even if error code is 101)

      If(Get(LastError)) = 0

      show custom dialogue1

      Else

      show different dialogue2

      Endif

       

      Script as follows does WORK

      Set variable($le = Get(LastError))

      If($le) = 0

      show custom dialogue1

      Else

      show different dialogue2

      Endif

       

      This does not make any sense.

        • 1. Re: Get (LastError)
          beverly

          this is not community feedback but a Discussion question. You may move this to a space where more users will see it or @TSGal or @TSPigeon can help you move it.

           

          beverly

          • 2. Re: Get (LastError)
            TSPigeon

            smfdist:

             

            Thank you for your post!

             

            As beverly mentioned this post may be better suited for Discussions or Report a Product Issue  as this does not relate to an issue or question about the FileMaker Community itself. I will move it do Discussions so you might receive further views and advice.

             

            I was unable to reproduce this issue with FileMaker Pro 15 (Advanced) on Mac OS X or the Windows Operating System. To attempt to reproduce I followed these steps:

            1. Created test.fmp12

            2. Created "Script"

                 Set Error Capture [On]

                 GoToRecord/Request/Page [With Dialog: Off ; "2"]

                 If [Get(LastError) = "0"]

                      Show Custom Dialog [ "Last Error was 0" ]

                 Else

                      Show Customer Dialog [ "Last Error was" & Get(LastError) ]

                 End If

            3. Ran Script with less than 2 records and received the Dialog "Last Error was 101"

            4. Ran Script with 2 records and received the dialog "Last Error was 0"

             

            The script seems to work as expected in my sample. Let me know if you have further steps necessary to reproduce.

             

            Are you able to replicate this in a new file?

             

            TSPigeon

            FileMaker, Inc.

            • 3. Re: Get (LastError)
              philmodjunk

              It looks like the key information needed to diagnose this is not shown. What script steps precede Get ( LastError ) in your script?

               

              In general terms, Get ( LastError ) has to be used immediately after the script step that produced the error. We often set a variable to that value when we need to do something with that error code at least one more script step later in the script and thus it is retained in the variable.

              • 4. Re: Get (LastError)
                User26869

                Hi

                 

                I know it will sound obvious, but make 100% sure that there is no script steps between the step that gives the error code and the if statement.

                Hope this helps

                 

                Chloe

                • 5. Re: Get (LastError)
                  David Moyer

                  smfdist wrote:

                   

                   

                  If($le) = 0

                  show custom dialogue1

                  Else

                   

                  Hi,

                  I know this is pseudo-code, but to make sure, the clause, in pseudo-code, should be

                  ($le = 0) and (Get(LastError) = 0)

                  Also, for convenience, please see my function for quick interpretation of the error code you get:

                  Get(LastError) Custom Function