9 Replies Latest reply on Jan 29, 2016 9:38 AM by Mike_Mitchell

    Validation Range in Table field

    Powerbook

      Hallo everybody,

       

      I'm getti quite crazy on trying to insert a validation in a table field.

      I need to allow creation of a new records only if the "Inserted Date" field is between a determinate date range.

      I tried to insert in the Validate by Calculation option this:

       

      1case with GlobalFileds:

      $$StartDate &"..."& $$EndDate

       

      2case with other table Fields:

      Inserted Date >= Table1::StartDate and Inserted Date <= Table1::EndDate

       

      But none of the two options are working

       

      What am I doing wrong?

        • 1. Re: Validation Range in Table field
          Mike_Mitchell

          Validation doesn't just work on record creation. It fires any time the field in question is called / changed. So if you're only trying to trap record creation, there's probably a better way to do it.

           

          What is "Inserted Date"? Is that a global field?

          • 2. Re: Validation Range in Table field
            Powerbook

            "Inserted Date" is a table field.

            Is the date when the record is created, but can be editable. Although must be in a controlled range.

            • 3. Re: Validation Range in Table field
              Mike_Mitchell

              I would probably opt for a scripted approach here. Unless you always need to hold that date within the defined range.

              • 4. Re: Validation Range in Table field
                Powerbook

                Actually I need to keep the creation and modifications of this date within a range.

                The field can be created and also modified later on.

                • 5. Re: Validation Range in Table field
                  Mike_Mitchell

                  Your original two cases will probably not work the way you intend. The first one wouldn't ever work, since you've defined a search range rather than a Boolean calculation. The second one's only going to fire if the Inserted Date field is changed.

                   

                  But in no case can you prevent a record from being created using field validation. The record has to be there for the validation to fire. If you auto-enter the creation date, then you've auto-entered the creation date. No validation will stop that. It'll only complain when you try to save the record. At that point, the validation will object and you would have to revert the record to prevent it from being saved.

                   

                  So I think you need to reconsider your workflow for this to work the way you want.

                  • 6. Re: Validation Range in Table field
                    Powerbook

                    I accept suggestions

                    I just have to prevent the change of inserting a date that is out of the range.

                    I was supposing that a Validation was there in order to prevent something to happen that is not allowed.

                     

                    How else could I check on a record that is being inserted?

                    • 7. Re: Validation Range in Table field
                      Mike_Mitchell

                      Use a scripted approach instead. Creating a data entry screen with global fields and a "Submit" button is one method. You can then simply save the data in the global fields into a real record once it passes your validation protocols.

                      • 8. Re: Validation Range in Table field
                        Powerbook

                        I was thinking about the script approach, but is quite complicate to apply to my solution, since data are inserted via a Portal that displays many related records. And creating a separate data entry screen will mess up things.

                        I thought that Filemaker was able to validate a field during record data entry.......

                        • 9. Re: Validation Range in Table field
                          Mike_Mitchell

                          Powerbook wrote:

                           

                          I thought that Filemaker was able to validate a field during record data entry.......

                           

                           

                          It can. I've already explained how it works. Your problem is your definition of "during record entry". Validation does not occur while the user is entering data. It occurs when the field with the validation applied is saved. So you can't stop someone from creating a record via field validation. You can only validate when they try to save and revert if it fails (which requires either a scripted approach, or direct user action).

                           

                          You can keep wondering why it doesn't work the way you think it should, or you can accept that it works the way it does and move on.

                           

                          I was thinking about the script approach, but is quite complicate to apply to my solution, since data are inserted via a Portal that displays many related records. And creating a separate data entry screen will mess up things.

                           

                          Inserting records via a portal is fast, easy, convenient, and a real problem if you need more than very basic control. Trying to apply validations to records entered in a portal is fraught with issues, not the least of which being if you revert the record, you'll wipe out ALL changes to ALL related records, as well as the parent record.

                           

                          If you need more control over data entry, I suggest you abandon the idea of entering records via portal and instead use a scripted approach. One example you can look at is in one of the Starter Solutions (can't remember which one right now, but you can look), where you use a popover to enter the data for the new record and insert it that way.