6 Replies Latest reply on May 29, 2013 12:30 PM by ErikWegweiser

    Record busy in another window?

    rivet

      Is there a way to check if record is open/active in another window on the same machine? I would like to check before I run a script.

        • 1. Re: Record busy in another window?
          Mike_Mitchell

          Not if it's open in another window per se, but you can check the record's open state by using Get ( RecordOpenState ).

           

          Mike

          • 2. Re: Record busy in another window?
            ErikWegweiser

            Under script control, with error trapping on, you can attempt to make an edit (such as using setfield). If the error returned is 301, you know the record is in use.

            • 3. Re: Record busy in another window?
              rivet

              Thanks Guys, looks like the 301 trap will be the trick.

              • 4. Re: Record busy in another window?
                BobGossom

                rivet,

                 

                I'd recommend Mike's "RecordOpenState" suggestion. It's much cleaner. When you set data you are editing the record and changing it's Modification Date/Time and Modified By information.

                 

                Bob Gossom

                • 5. Re: Record busy in another window?
                  rivet

                  yes but it seems only to work if you are in the actual window that the record is active, other wise it will return '0' in all other windows

                  • 6. Re: Record busy in another window?
                    ErikWegweiser

                    Yes, Get(RecordOpenState) only returns the state of the record as you are creating/editing it. If another user/window is editing a record and has not saved (committed) the record, the Get(RecordOpenState) function in 'your' window will still show '0' because you have not started editing it (indeed, you can not).

                     

                    Only attempting to edit will verify not-in-use.

                     

                    One trick you might need (depending on the circumstances) is to 'open' the record, via script, perform various actions—via script or manually—then commit the record. That way, the record remains in use by you until the commit, rather than opening and committing with various actions, with the possibility of being interrupted by another user (or window!) performing an edit on the same record.

                     

                    For some 'old school' modal dialogs, I have added 'on record commit' layout script trigger controls to prevent the user from accidentally clicking outside a field and inadvertently committing a record before they're done. That prevents the above scenario and allows for reverting changes, if desired.

                     

                    HTH