Layout fields validation

General support questions.
PostPosted: Wed May 10, 2006 3:22 pm
I'm working on a section of our solution that involves document templates that are filled and generated based on fields in an "OFFERS" table.

This table includes all fields that are in any and all templates.

Each of the dozens of templates have different amounts and cominations of the fields from that OFFERS table.

Each template has its own "DATA" layout to fill out just the fileds necessary to generate that template (the template is created with merge fields embedded in the text).

My objective is to be able to stop the users if ANY of the required fields for that template are not filled in.

Because the fields used in a template are from a table with MANY more fields than what would be used in that template, I cannot simply program a validation at the field level (because not all fields in that table would be filled in each record).

I'm trying to avoid having to write a script for every one of the dozens of templates to validate every field in them all. I was hoping there was a function that would validate that all fields on a given layout are filled.

Is there?

If not, any other ideas?

Thanks in advance...

Nate
SeedCode Staff
SeedCode Staff
Posts: 2764
Joined: Thu Nov 20, 2003 11:01 am
PostPosted: Thu May 11, 2006 6:38 am
I don't *think* you can reliably use Get(LayoutName) in a data file's validation when the layout in question is in another file. A couple things suggest themselves...

a) You could base the validation on a field that let you know what "type" of record you're editing (reflecting what layout was involved). So your validation calcs would only test for field X being present when the record was of type Y or Z. Then all you have to do is set this "type" field before taking the use to the appropriate data entry layout.

b) Providing that the user can tab into all the required fields on each of your data entry layouts, you could have a single script that validated any such data entry layout by using GoToField(Next) to loop through all the fields on the layout to make sure they're filled out.
John Sindelar
SeedCode
PostPosted: Thu May 11, 2006 7:21 am
Your #b was the piece I was missing.

Nice thinking, John!!!!!!
PostPosted: Thu May 11, 2006 7:30 am
...now the follow up question to that:

what to add to the script to indicate which fields were not filled in.

I suppose they could be outlined in red, and/or listed in a box at the top of the layout or something like that.

Don't want to reinvent the wheel here...

Nate
SeedCode Staff
SeedCode Staff
Posts: 2764
Joined: Thu Nov 20, 2003 11:01 am
PostPosted: Thu May 11, 2006 8:02 am
You can certainly do a lot here. On the simple side you can record the name of any empty fields to a global field or variable when your script is "in" the field by using Get ( ActiveFieldName ) and then display a custom dialog at the end of the script listing the fields that were empty.

Or, you could just stop the script in the first empty field (your cursor will already be there) and show a message indicating that it has to be filled out.

Coloring the field red probably requires more redundant objects than I'd like, but you could certainly do that also, having built a list of offending fields using the Get ( ActiveFieldName ) trick above.

Some people use auto enter calcs for this. For example, if you have a field called "First Name" you might have that auto enter some light grey text like "first name" on record creation. Then your validation script wouldn't test for empty, it would test for "first name"*. If you find validation errors, you'd set a field in the record itself to indicate that it was incomplete. Your auto enter calcs would turn "first name" red if the field still contained "first name" and the incomplete field was true.

A variation on this uses a second set of fields instead of doing the instructions and colors in the actual data entry fields.

Both approaches seem like a bit much, but it looks very slick.

*In order to make your tests simpler, consider pulling your instruction text ("first name" in this case) from field comments, so that you can use something like this as your not-filled-in test:

trim ( Get ( ActiveFieldContents ) ) = "" or
trim ( Get ( ActiveFieldContents ) ) = trim ( FieldComment ( YourFileName ; Get ( ActiveFieldName ) ) )
John Sindelar
SeedCode
PostPosted: Thu May 11, 2006 8:37 am
wow, John...thanks for the quick response!

Right now I'm hung up with the fact that all of the fields in my layouts that need filled in are separated into a few Tab Controls. The "Go to Next Field" is not seeing anything in any of the Tab Controls, other than the one that is currently open.

Do you know of a way around this? Seems like it would have to be simple, but I'm stumped?

Nate
SeedCode Staff
SeedCode Staff
Posts: 2764
Joined: Thu Nov 20, 2003 11:01 am
PostPosted: Thu May 11, 2006 8:47 am
You can script moving from tab to tab by using GoToField where the field in question is only on 1 tab. Some developers use a special repeating field for this, placing a different repetition on each tab.

Once you can do that, I think you'll need to think of your tabs as separate layouts (in a sense) and do something like this:

Code: Select all
SetVariable, 1
Loop
   Go to Field ( YourTabField, repetition (Variable)*
   if ( Get ( LastError ) <> 0 ) **
      Exit Script
   End If
   Go to your first field, record its name.
   Loop
      Test for the field being filled in.
      Go to Next Field
      Exit loop if the field name matches the one you recorded above.
   End Loop
   SetVariable, Variable + 1
End Loop


* This goes to the first tab, then the second, etc as the variable increments.
** Exits the script when there is no available repetition of this field- ie no next tab.
John Sindelar
SeedCode
PostPosted: Thu May 11, 2006 12:42 pm
John, you are my FileMaker HERO.

Proficient, technical, and succinct.

Nice.

Return to General Support

Who is online

Users browsing this forum: No registered users and 2 guests

cron
(855) SEEDCODE
[email protected]
Follow us: