11 Replies Latest reply on Jul 24, 2017 3:41 AM by cril

    Record locked by other user

    cril

      I am developing a database solution that I want me and my family/helpers to be able to access on their iPhones. I run a small stud yard which makes nearly no money but is fun. Hence I don't want to use FMP server for obvious cost reasons and neither do I want to devote a whole computer to it. I can get my IOS GO solution to share into my running database just fine but it is also running an emailing program constantly. This works fine most of the time but every now and again I get a message come up on the screen saying a record is locked and stopping the emailing script.

       

      So the question is how do I capture that record locked error so that I can come back to the error record later? Everything I've looked at refers to server whereas I just want to use the sharing facilities of FMPro Adv 14.

       

      Thanks

        • 1. Re: Record locked by other user
          coherentkris

          Get(RecordOpenState) can be used in a script to detect lock condition so you can handle appropriately.

          You can always trap for errors on a specific script step with Get(LastError)....

          i.e.

          -any script step here-

          set variable ( $err ; Get(LastError))

          if ( $err = 0 ; no error has occurred do this ; an error has occurred do this)

          2 of 2 people found this helpful
          • 2. Re: Record locked by other user
            philmodjunk

            Whether hosting the file using FileMaker Pro Or Server, record locking will be the same, so what you read about this issue should apply to your set up even if they discuss in terms of server.

            • 3. Re: Record locked by other user
              philmodjunk

              To test to see if a record is locked I'd do it this way:

               

              Set Error Capture [on] ---> this step keeps error message from interrupting your script if record is locked

              Open Record

              If [ Get ( LastError ) > 0 // record is locked ]

                Do what you need to do when record is locked such as appending a primary key value to a list for later update

              End If

              1 of 1 people found this helpful
              • 4. Re: Record locked by other user
                cril

                Thanks for that - I've used your suggestion rather than the record locked check which I couldn't get to work. I wonder if that only works on server which I don't have set up at the moment.

                • 5. Re: Record locked by other user
                  cril

                  I'm trying to use this with a go to related records step and it doesn't work as a next step check. Do you have any any examples of its successful use as it should be the correct way of checking rather than failing an open or set field step?

                  • 6. Re: Record locked by other user
                    philmodjunk

                    Checing to see if a record is locked can fail because another user or script can lock the record sfter your script finds that the record is unlocked but before your script can lock it. What I recommended is better because it attempts to open (and thus lock) the record before checking for an error. This way you both check for a lock and lock out other users with a single action.

                     

                    As I posted before, you get the same behavior whether hosting via server or Pro.

                     

                    I can't tell what problem you are having with Go to related records as an edit lock does not keep such a step from working. The step does not modify data and thus brings up a found set of records regardless of any locks on the records.

                    1 of 1 people found this helpful
                    • 7. Re: Record locked by other user
                      cril

                      Yes the only guaranteed way of checking and locking is the open or set field step I'm finding. Can't simulate any instance where recordstate works. I only mentioned the go to related record in case my use of a relationship voided the get(recordstate) fiction.

                      • 8. Re: Record locked by other user
                        philmodjunk

                        "Can't simulate any instance where recordstate works."

                         

                        But that should work. It's just not 100% reliable.

                        • 9. Re: Record locked by other user
                          Vaughan

                          Get ( lasterror ) can return values < 0.

                          1 of 1 people found this helpful
                          • 10. Re: Record locked by other user
                            philmodjunk

                            Get ( RecordOpenState )

                             

                            will not generate an error code. It returns a value that either tells you that the record is open, and thus locked, or not open and thus unlocked. You can look up this function call in Help to learn the specific values returned.

                            • 11. Re: Record locked by other user
                              cril

                              good point so the check should be for =0!