8 Replies Latest reply on Nov 30, 2016 1:09 PM by philmodjunk

    Button to add permanent timestamp

    ronniemilsap

      Using Filemaker 12 Pro

       

      This seems like a simple task and I was close to a solution at one point, but I seem to have lost my way.  I simply want the user to click a "Checkout" button and for the current date and time to be applied to a field that will permanently hold the value (field will no longer be editable). The closest I got was adding a timestamp, but it continued to use the current timestamp every time the button was clicked.  I've edited the script so many times that it has become useless.  At this time I am using:

       

      Button Setup

      Set Field

      Specify Target Field (Chose my field and clicked OK)

      Calculated Result:

           Table::Check Out; Timestamp (date ; time)

       

      When I click OK, I get error "An Operator (e.g. +,-,*,...) is expected here."  Clearly I have no clue what I'm doing.

       

      Any ideas are appreciated.  The closest solution I've found is here: https://www.reddit.com/r/filemaker/comments/2dyaaj/button_timestamp_help/

      But it hasn't been much help.

       

      Thanks

        • 1. Re: Button to add permanent timestamp
          erolst

          ronniemilsap wrote::

          [...]

          Button Setup

          Calculated Result:

          Table::Check Out; Timestamp (date ; time)

          1. You do not want to reference the target field again; you already selected it in that other setting.

           

          2. The function you want is Get ( CurrentTimestamp )

           

          So this reads

           

          Set Field [ target field: Table::Check Out ; calculated result: Get ( CurrentTimestamp ) ]

          1 of 1 people found this helpful
          • 2. Re: Button to add permanent timestamp
            ronniemilsap

            Great, Thank you, erolst.  Now I am back to where I was in the past.  It is adding the Timestamp, but the field still accepts a new timestamp each time the button is clicked.  How do I render the field locked once the initial value has been assigned?

            • 3. Re: Button to add permanent timestamp
              ronniemilsap

              ...And after reading up on it a bit, I would be good with locking the entire record upon clicking the checkout button(unless it locks out a full privileged user) since the entry should no longer be edited once the visitor is checked out.  That is probably my preferred approach.

              • 4. Re: Button to add permanent timestamp
                erolst

                Aah, yes; there are two ways. With your current single-step button, use this to calculate the result:

                 

                Case ( IsEmpty ( Table::Check Out ) ; Get ( CurrentTimestamp ) ; Table::Check Out )

                 

                which will always write into the field, but in one case simply use what's already in.

                 

                or, if you do not to always touch the field (eg to prevent altering a record modification timestamp), you need a script to attach to the button:

                 

                If [ IsEmpty ( Table::Check Out ) ]

                  Set Field [ Table::Check Out ; Get ( CurrentTimestamp ) ]

                End if

                 

                You can combine this with a Hide if calculation for the button itself: not IsEmpty ( Table::Check Out )

                1 of 1 people found this helpful
                • 5. Re: Button to add permanent timestamp
                  ronniemilsap

                  Using exactly this as the script for the button:

                   

                  Case ( IsEmpty ( Table::Check Out ) ; Get ( CurrentTimeStamp ) ; Table::Check Out )

                   

                  RESULTS:

                  1. If there is no data in the field, the timestamp is recorded.

                   

                  2. When I click on a record that contains data it does nothing to the field - BUT -  if I click on the checkout button for a different record, it modifies the data on the record that I previously attempted to change.

                  • 6. Re: Button to add permanent timestamp
                    ronniemilsap

                    I think I've resolved the problem by toggling off "Modification" in the Auto Entry options for the Check Out field.

                     

                    Thanks, erolst, for your help!

                    • 7. Re: Button to add permanent timestamp
                      BruceRobertson

                      Use the script as described by erolst.

                       

                      If [ IsEmpty ( Table::Check Out ) ]

                        Set Field [ Table::Check Out ; Get ( CurrentTimestamp ) ]

                      End if

                      • 8. Re: Button to add permanent timestamp
                        philmodjunk
                        I would be good with locking the entire record upon clicking the checkout button(unless it locks out a full privileged user) since the entry should no longer be edited once the visitor is checked out.

                         

                        This can be done through record level access control inside Manage Security. You can set up a "lock expression" on the non full access privilege set(s). That only allows editing the record if this timestamp field is empty.