9 Replies Latest reply on Oct 4, 2013 8:01 AM by Fred(CH)

    Restrict the field not to be edit after record committed.

    tcenguyen

      Hi,

      Is there a way that when user is committed a record [save]. When that user browse to that record, he or she can not edit the content of the record. Example: First_Name= John, Last_Name= Smith. After they commit the record. Last_name and First_name can not be editable.

      I have tried the Database setting, but I have to closed the database and reopen the databse, then it worked, But when the database is open, They still can edit the record.

       

      Thanks

        • 1. Re: Restrict the field not to be edit after record committed.
          ninja

          Hello tcenguyen,

           

          Yes, you can do this, but it is often a poor choice.

           

          You can restrict access to the record by setting "limited..." edit privieges under the security settings.  You would set that user's Edit privileges to

           

          "Allow edit when:"  IsEmpty (Table::First_Name) and IsEmpty(Table_Last_Name)  or whatever combo is most appropriate.

           

          This will update when the record is comitted and does not require a restart.

           

          The problem I've consistently run into when I do this, however, is that is restricts the user from correcting their own typographic errors.

          If a user mis-types the last name, then commits the record, they cannot correct their mistake.

           

          Can you do it? Yes...but consider if it will be helpful, or if another approach such as a timestamp field may be more useful.

          Setting a modification timestamp on the record, then setting the edit priveleges to allow edit for the next ten minutes or so may be more user friendly.

           

          Allow Edit when Minute(    (Get(CurrentHostTimestamp) - Get(ModificationTimestamp )   ) < 11

           

          Try it both ways and see which is preferable...

          1 of 1 people found this helpful
          • 2. Re: Restrict the field not to be edit after record committed.
            tcenguyen

            Hi Ninja,

            Thanks for the tip.  However, ModificationTimestamp function is not a valid.  I am using version 11.3.

             

            Please advice.

            • 3. Re: Restrict the field not to be edit after record committed.
              philmodjunk

              True, but you can define a field that auto-enters the modification timestamp and you can modify Ninja's expression to use it in place of a Get function that doesn't exist.

              1 of 1 people found this helpful
              • 4. Re: Restrict the field not to be edit after record committed.
                tcenguyen

                Guys,

                Thanks very much for the help and advices.

                 

                Tcenguyen

                • 5. Re: Restrict the field not to be edit after record committed.
                  Bobster

                  Hi Tcenguyen,

                   

                  For a level of security that allows mistakes to be corrected, but accidental changing of the names is prevented, have a look at this file.

                   

                  It might meet your requirements,

                   

                  Regards,

                   

                  Bob.

                   

                  Bob Stuart

                  Lord Of The Files
                  Think Data Pty Ltd
                  Noosa
                  Queensland
                  Australia.

                   

                  +61 7 5442 5624
                  +61 413 350 993

                  • 6. Re: Restrict the field not to be edit after record committed.
                    ninja

                    Sorry,

                     

                    I meant to give the general idea, not the specific code and I was unclear in doing so...(like I didn't say that's what I was doing )

                     

                    The Get (Modification Timestamp) I typed is not a function, it was just how my brain saw the following:

                    Create a "modificationTS" field...

                    Set it to update to Get(CurrentHostTimestamp) whenever the record is modified

                    Plug that "modificationTS" field into the Privileges expression... not the literal Get(modificationTimestamp) I typed...you are correct, it is not a real function.

                     

                    Again, sorry for taking the mental shortcut and not being very clear.

                    • 7. Re: Restrict the field not to be edit after record committed.
                      AlanStirling

                      Hi Ninja

                       

                      Just a small point - your use of Get(CurrentHostTimestamp) in this particular situation might not be the most reliable, since you are comparing that timestamp with the Modification Timestamp, which comes from the Client machine. If the clocks in the server and the client start to differ, your record lock may become erratic.  If the comparison uses the time from the clock in the client machine then there is less chance of error.

                       

                      There is also the issue of handling the switch to Daylight Saving time, particularly for late night users ...

                       

                      Best wishes - Alan Stirling, London UK

                      • 8. Re: Restrict the field not to be edit after record committed.
                        ninja

                        Hi Alan,

                         

                        A valid point.  Using the Host Timestamp does, however, bypass the ability of the user to control the timestamp by changing the time on the client machine.  Unless I misunderstand something, a user can foil the local timestamp by changing the clock on the client machine and generate a "false" timestamp.  Using the Host Timestamp, the Timestamp cannot be altered from the client machine.

                         

                        Again, it is a valid point regarding Daylight Savings time...have to noodle on that one for a while.  Any suggestions are welcome.

                        • 9. Re: Restrict the field not to be edit after record committed.
                          Fred(CH)

                          Hi all,

                           

                          I think Bobster's solution is effectively very clever.

                           

                          However, i think we can now also use the triggers for that :

                           

                          It is a bit more work on the layouts but leave a cleaner structure. All concerned field objects must have an OnObjectModify trigger that fire a simple script like :

                           

                          #Script to be triggered when OnObjectModify for ALL desired fields

                          If [ Get ( RecordOpenState ) = 2  ]

                              #Or whatever other test like : Globals::Lock or Privilege Name etc....

                             Undo/Redo [ Toggle ]

                             Show Custom Dialog [ Message: "Modifications are no longer allowed"; Default Button: “OK”, Commit: “Yes” ]

                          End If

                           

                          What do you think about ?

                           

                          Bye, Fred