8 Replies Latest reply on Dec 13, 2013 3:11 PM by erolst

    Locking or Notify upon record editing


      I have created serval databases typically used by field personnel for various types of data collection. There have been issues with inadvertently editing data after records have been created. I do not want the record to be completely locked so as to not allow any edits at all but some way to at least alert the user prior to editing.

      I tried using the OnObjectModify script trigger but this alerts for every key stroke inculding new records. If this dialog box could pop up not for new records and only after a field has been edited, that would be sufficient.


      Another idea I tried to figure out was to use a checkbox to lock the record entirely and the user would have to unselect the checkbox in order to make any edits. However, I could not figure out how to lock all of the fields on the form through this check box. I would also need the checkbox to be reselected after the record has been edited or created.

        • 1. Re: Locking or Notify upon record editing

          Hi, the idea with the checkbox is easy. You need to make a field with value 0 or 1. When you lock the record you set the field to 1. You make a privilege set and in edit record you will have a calculation if the value is 1 then do not edit. And in the layout you put a lock and unlock picture with set filed 0 or 1. You can also set automatic the field to 1 on record commit. So the user will have to unlock a record to edit it. You can also use conditional formatting and put a yellow background so the user will know that he is in an edited mode

          • 2. Re: Locking or Notify upon record editing

            What about a script trigger "OnObjectEnter"  something like ....


            If [Self >= "*"]

            Display custom Dialog Box [ This field contains data, are you sure you want to edit it?]

            If[ get (lastmessagechoice) = 2]

            Halt script



            • 3. Re: Locking or Notify upon record editing

              I am almost there, I now have 2 scripts one upon object enter to notify if the record is locked and the second will undo any edit put it if the record is locked. 


              I am struggling with how to lock the record upon record commit though. 

              • 4. Re: Locking or Notify upon record editing

                There is a OnRecordCommit Layout Scrpit Trigger

                1 of 1 people found this helpful
                • 5. Re: Locking or Notify upon record editing

                  The main idea is to use the privilege set. Then the record is automatically locked down unless you change the lock to unlock.

                  1 of 1 people found this helpful
                  • 6. Re: Locking or Notify upon record editing

                    Ok, hopefully the last issue with this....


                    I was able to get everything to work setting to lock/unlock using 1/0, however when I tried to translate this to using "Lock" and "Unlock", the OnRecordCommit script will not select "Lock".  When "unlock" is selected the script will unselect both.  I have these set-up as radio buttons, any suggestions. 


                    Here is my working script with numbers but will not work with "Lock" and "Unlock"


                    If [Recon::lock = 0]

                         Set Field [Recon::lock; Recon::lock=1]

                    End If

                    • 7. Re: Locking or Notify upon record editing

                      in the set field step you should not say Recon::lock=1 it should just be 1.  Make sure you are putting the “Lock and Unlock” in “” in the calculation.







                      Charles Wiltgen

                      Creative Customized Programming, Inc


                      • 8. Re: Locking or Notify upon record editing

                        What you're doing here…


                          Set Field [Recon::lock; Recon::lock=1]


                        doesn't work because this part …


                        Set Field [Recon::lock


                        … already specifies the field to write to, so you don't have to (and can't!) specify it again as target in the result calculation, which you're doing here:




                        In effect you're saying first "Do this if lock = 0", and then calculate the result of the expression "lock = 1", which is False / 0, so is looks as if nothing's happened (if lock = 0 set lock to 0 …).


                        I recommend simply using a number field with 1/0 and writing the actual words Lock and Unlock as labels on the layout. This makes clear the meaning within the UI, and the field name makes the meaning clear to you; no need to actually store these words anywhere.


                        Then it just takes one line to toggle your field:


                             Set Field [ Recon::lock; not Recon::lock ] // ( not 1 ) = 0, and vice versa


                        and you can query it in calculation/scripts with If [ recon::lock ] or If [ not Recon::lock ], which pretty much reads like natural language.


                        If you insist on using the actual words, use


                            Set Field [ Recon::lock; Case ( Recon::lock = "lock" ; "unlock" ; "lock" ) ]


                        Or in the more talkative If/End If construct:


                        If [Recon::lock = "unlock" ]

                             Set Field [Recon::lock; "lock" ]


                            Set Field [Recon::lock; "unlock" ]

                        End If