5 Replies Latest reply on Dec 17, 2012 10:18 AM by philmodjunk

    Prevent Entry of Date Before Today

    AndrewCohn

      Title

      Prevent Entry of Date Before Today

      Post

           Hi all, Quick newbie question.

           I have a field on a Purchase Orders module that I want to restrict the entry of a date to today's date or any future date.

           I guess I could set up a On Exit script trigger, and write a script that checks to make sure the date of the field is >= // and if it doesn't alert the user.

           But is there a way to do something similar without using a script?  Is there a way to set the field definition to only allow a date today or after?

           Thanks!

           Andrew

            

        • 1. Re: Prevent Entry of Date Before Today
          philmodjunk

               In field options, you can set up this validation calculation:

               Self > Get ( CurrentDate )

               and any dates entered/selected prior to today will trip an error message.

          • 2. Re: Prevent Entry of Date Before Today
            AndrewCohn

                 Okay, that seems like it would work.  One question, would this calculation run on a record that was created previous?  For example, if a user enters today's date on a new PO today, and then they go back to look at the same layout and record tomorrow, and their focus ends up on this field, will it allow the field to keep yesterday's date?

            • 3. Re: Prevent Entry of Date Before Today
              philmodjunk

                   The validation only kicks in if they attempt to modify the value of this date field. And you have the option of enabling a strict validation where the user is not permitted to enter invalid data or give them the option to override the validation warning.

                   You can also construct a more sophisticated validation calculation where you use an additional field to auot enter the creation date of the record. Your validation calculation could then reject all dates entered earlier than the date in the creation date field instead of the current date.

              • 4. Re: Prevent Entry of Date Before Today
                AndrewCohn

                     Hm, since my database already has auto-created fields in virtually every table for Date Record Created, it sounds promising to try that.

                     So it would be something along the lines of 

                     Self >= Get(SameTable::zAutoDateCreated)

                     Something like this??

                • 5. Re: Prevent Entry of Date Before Today
                  philmodjunk

                       No get function, just:

                       Self > zAutoDateCreated

                       But run some tests to make sure that zAutoDateCreated manages to auto-enter the current date before this validation kicks in for the first time on a newly created record. It should, but if not, you'll need a more sophsiticated expression that refers to Get ( CurrentDate ) when zAutoDateCreated is empty.