1 Reply Latest reply on Jul 19, 2015 6:46 AM by philmodjunk

    Using a button to add a CurrentDate to field.

    MattStephens

      Title

      Using a button to add a CurrentDate to field.

      Post

      No matter how many different ways I have tried this - and it seems like it should be the easiest thing to do - I am unable to get my button to enter the current time into a field.

      I have the script below and the field name and table name is correct. No matter what I do, I never get a time entered in the StartTime or EndTime fields when I click these buttons...

      Very frustrated because I build this entire database in about 3 hours and have spent about 6 just trying to get this last feature to work..!

      Thanks so much for any assistance..

      Cheers, 

      Matt

      Screen_Shot_2015-07-19_at_4.00.48_pm.png

        • 1. Re: Using a button to add a CurrentDate to field.
          philmodjunk

          Two things show up here:

          1) all script steps that start with "insert" fail to work unless the field specified is also present on the layout that is current at the time the step is executed. You get a "silent failure" if it is not. (Silent Failure: No error message is displayed, you only know that an error occurred because the field isn't set and an error code is returned.)

          2) You are creating a new record after inserting the current time. Thus the record you are looking at when you check results is very likely not the record modified by your Insert Step.

          Suggestion 1:

          Use Set field instead of Insert:

          Set Field [ Log Start::StartTime ; Get ( CurrentTime ) ]

          Note While this step does not require that the field be present on the current layout, it STILL requires that the current layout context be such as to make modifying this field something that is possible.

          Suggestion 2:

          Implement this one step at a time so that you can see how each step affects your results. Start with just the set field step while on a layout based on the Log Start table ("log End" is based on this table as shown by the name in parenthesis.) Then add the new record and Go To layout steps one at a time so that you can see how they affect your results.