6 Replies Latest reply on Oct 24, 2013 4:51 AM by Beowulf

    Automatically entering time after selecting field

    Beowulf

      Title

      Automatically entering time after selecting field

      Post

           I’m using Filemaker Pro 12 on Windows 7.

           I have two fields with current time and a third one which calculates the time difference between the two fields.

           I want to have the current time entered into a field after I’m selecting it. For that I’m using a script trigger with “On Object enter” with “Get (Current time)”. Now I wondered if there is maybe an easier way to accomplish it but I think with auto-enter it doesn’t work since the time is created when you create a new record?

           Auto-enter calculation of the third field: Field2 – Field1, with “do not replaces existing value of field” uncheck. I have to uncheck it, since Field 1 is always entered first and therefore at the time of calculation in Field2 there is no time entered yet and the calculation gives me a minus value. Is there a better formula for calculating it, so I don’t have to uncheck this option? Since I would like that you can't accidentally overwrite the calculated result.

           The other thing is that I want to prevent that users change the time again by accidentally clicking on the field. I know the option to uncheck “allow user to override during data entry”. The problem then is that this only works if I have the script trigger changed to “On Object modify”. But I’m reluctant to use this script trigger since for new users it’s easier to just click into the field to get the current time then to remember that you have to enter something into the field for the script to get triggered.

           Maybe I could lock the field with user’s privilege, so they are allowed to enter new records but not modify it? But still there is the danger that if you have these privileges you accidentally change the time. I would prefer a solution where I intentionally have to unlock the field to change anything.

           Thanks a lot for any help. :)

        • 1. Re: Automatically entering time after selecting field
          philmodjunk

               It sounds like your calculation that subtracts the time values should be in a field of type calculation instead of an auto-entered calculation. With the field of type calculation, the field contents of that field cannot be edited.

          • 2. Re: Automatically entering time after selecting field
            Beowulf

                 That helped for the third field, thanks Phil.

                 But I still have the problem that the first two fields can by modified by accidentally clicking on it. If the script trigger is "On object entry", which I would like not to change. There I can't use the type calculation since these have a script trigger "On object entry" to get the current time. Unless there is a formula to get the current time by clicking the field which I can enter as a calculation?

                 Also to see the correct calculation I always have to click in the third field. Because it firsts calculates a minus value as the first field is always clicked on before the second field. Which means that when the first field gets the current time the second field is still on 00:00:00 and a minus value is calculated. Isn't it possible that the calculation is only done after in both fields the time is entered (via clicking in the field)?

            • 3. Re: Automatically entering time after selecting field
              philmodjunk

                   How would we tell the difference between clicking the field accidentally or on purpose?

                   Since the user's interaction with the layout is identical in either case and FileMaker can't read the user's mind, I can't see any design change that can be made that allows the user to click the field deliberately and prevents the user from clicking it accidentally.

                   You could modify the script, however, to show a confirmation message such as "do you want to enter the current time?" and then only do so if the user selects yes or your script could avoid entering the time if a value is already entered in the field...

              • 4. Re: Automatically entering time after selecting field
                Beowulf

                     Sorry, I should have been more precise.

                     Normally the first current time, which is entered is the correct one. So what I would like to prevent is that accidentally someone enters the current time in the field again. But it would also be good, if one can change the "current time", just in case. Because in this table minutes and seconds do matter in these fields.

                     Therefore is it possible to combine your two options you described, i.e. having a script, which asks for a conformation if you want to enter the time in a field, where a value is already entered in it? So, the first time you enter the current time in the field, the script is not activated but the second time and thereafter it is. I guess a script trigger "on object modifiy"? But I'm already using the option "on object enter" to get the current time. Is it possible to have two script triggers in one field?

                • 5. Re: Automatically entering time after selecting field
                  philmodjunk

                       You could set up the OnObjectEnter trigger to perform a script to enter the current time if the field is empty and do nothing if it is not:

                       If [ IsEmpty ( YourTable::TimeField ) ]
                          Set Field [YourTable::TImeField ; Get ( CurrentTime ) ]
                       End If

                  • 6. Re: Automatically entering time after selecting field
                    Beowulf

                         That worked perfect.

                         Thanks again for your help, Phil! :)