7 Replies Latest reply on Feb 22, 2016 2:56 PM by BillisSaved

    script or key assignment to add current date by using space bar taps

    Jtmwalk

      I am trying to expedite the data entry process when in date fields.  Is there a way use the space bar (In Focus - IN a date field) to enter current date in a field. Example might be, based on the number of space bar taps, the data in the field, would progressively enter information.

       

      1x = Enters:Current Month & on field exit - (Defaults to day 1, and Current Year)

      2x = Enters:Current Month & Current Date & on field exit - (Defaults Current Year)

      3x = Enters:Current Month & Current Date & Current year

       

      I know there is a (Ctrl - ) for "today", and (Ctrl : ) for Current Time,  I would just find it faster using thumb to single tap, rather than combination keystrokes to accomplish.

       

      I searched this topic, and unable to locate past discussions - any help?

      Thank you in advance, as always!

        • 1. Re: script or key assignment to add current date by using space bar taps
          alecgregory

          You can do this with a combination of an OnObjectKeystroke script trigger and a OnObjectExit trigger

           

          Essentially:

           

          OnObjectKeystroke Script

          If [Code ( Get ( TriggerKeystroke ) ) = 32 // Space Key is Character 32]

            SetVariable [$$SPACE_COUNT] = $$SPACE_COUNT + 1

            If [$$SPACE_COUNT = 1]

              SetField [YourField] = Month ( Get ( CurrentDate ) )

            Else If [$$SPACE_COUNT = 2]

              SetField [YourField] =

                Month ( Get ( CurrentDate ) )

                  & "/"

                  & Day ( Get ( CurrentDate ) )

            Else If [$$SPACE_COUNT = 3]

              SetField [YourField] = Get ( CurrentDate )

              Exit Object (either with a Go To Next Field, Go To Field, or Commit Records step)

            End If

            Exit Script[0]

          End If

          Exit Script[1]

           

          OnObjectExit Script

          If [$$SPACE_COUNT = 1]

            SetField [YourField] =

              YourField

                & "/"

                & Day ( Get ( CurrentDate ) )

                & "/"

                & Year ( Get ( CurrentDate ) )

          Else If [$$SPACE_COUNT = 2]

            SetField [YourField] =

              YourField

                & "/"

                & Day ( Get ( CurrentDate ) )

                & "/"

                & Year ( Get ( CurrentDate ) )

          End If

          SetVariable [$$SPACE_COUNT] = ""

          Exit Script[1]

           

          That will handle the basic case of users hitting the spacebar between 1 or 2 times and then exiting the field manually. If they hit the spacebar three times they will be automatically taken out of the field.

           

          It doesn't handle the case where they type other information into the field after hitting space, though it could be adapted to do that.

          • 2. Re: script or key assignment to add current date by using space bar taps
            Jtmwalk

            This is a great solution to making the space bar taps function as desired, but I have a further question on this one.

            Is it possible to create these scripts to be used as a global function for any/all Date fields when they are in focus?  I would think then, to activate this functionality, I would only have to use the check box function on which/what scripts to run after exiting fields.  These script steps look like I would have to show the field NAME for EACH date field, and would create multiple scripts, no?

            I was hoping for a global function, whereas tapping the space bar in any date field, would add the date and month data, but if a space bar is used in a text field, it would act only as a space.  Is there a way to insert a Self function where the field name is required?

            Is something like this possible?

            • 3. Re: script or key assignment to add current date by using space bar taps
              siplus

              if you want to expedite data entry in a date field, you should head for reducing the keystrokes. With your idea you go up to 3 spacebar keystrokes in order to get today's date. Another quickenter approach could be to type d or m or y to cover your 3 alternatives: one keystroke covers all, and due to specific key to function association, easy to remember.

              • 4. Re: script or key assignment to add current date by using space bar taps
                Jtmwalk

                Even that option of typing M / D or Y would work as well to expedite entry.  Where I am lost, is when I type any letter in a date field, it error messages to: The value of this field must be a valid date in the range of year 1-4000 and should look like "12/25/2003".  Only leaving the option of revert.  How do I set this function to perform globally on ALL date fields?

                Am I missing something really simple on this one?

                • 5. Re: script or key assignment to add current date by using space bar taps
                  siplus

                  the

                  Patterncount(FieldType ( Get(Filename); Get ( ActiveFieldName )) ; "date")

                   

                  violin will play a pleasing note when you are in a date field.

                  • 6. Re: script or key assignment to add current date by using space bar taps
                    siplus

                    use it at layout level, ofc (onLayoutKeystroke trigger).

                    • 7. Re: script or key assignment to add current date by using space bar taps
                      BillisSaved

                      Good afternoon Jtmwalk,

                       

                      I hope your day is going well. Do the date fields always contain a value? If so, you might consider using an auto-enter calculation in the field configuration (e.g., Get (CurrentDate) ) that sets the current date as the default value when you create a record. Otherwise, I think siplus has a good solution. Good luck!

                       

                      God bless,

                       

                       

                      Bill