Jump to content

Script step that validates a field


This topic is 4758 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi, I'm looking for a script step (or custom function) that will allow me to check the validation rules associated with a field from within a script... (so I can do something like If (field passes validation check)...

The problem is that when I use the "commit record" step in the script, the user gets presented with the error message defined in the field options settings from within the database manager window and the script pauses for their input (revert or cancel). I'm looking for someway to prevent that message box from popping up and scripting my own procedure (revert the record and show a different dialogue)

I've already looked at this (http://fmforums.com/forum/topic/72788-scripting-field-validation/) but I'm looking for a way to do this purely from within a script (without creating a new TO) and that uses the validation rules set in the database manager.

thanks!

Link to comment
Share on other sites

Have you also looked at:

http://fmforums.com/...286#entry362286

Thanks,

Ok , now I'm coming at this from a different angle...How can I create a script step that searches in the same field (with the same name in each table) in which ever table you're currently in for duplicates using the "!" operator, and then counts the number of records found?

in this example (which uses imaginary functions that don't exist to help me explain) each table has a field named "FIELD_TO_BE_SEARCHED"

I want something like this: Count ( Find ( Get (LayoutTableName) & ::FIELD_TO_BE_SEARCHED) )

thanks!

Link to comment
Share on other sites

Don't confuse functions with script steps. To get the results of a find, you must actually perform a find (and lose your current found set in the process - though this can be solved by opening a new window for the find).

You can use the Set Field By Name[] step to avoid hard-coding the field to be searched.

---

Just to make sure we understand the starting point: there is no good solution for this. When Filemaker added the OnObjectValidate trigger, they did not add a IsUnique() function at the same time. As a result, there is no elegant way to predict the result of this type of validation (and perhaps some other types as well).

Link to comment
Share on other sites

There is a very big difference between a reference to a field and the field's name as text.

GetField ( TableICareAbout::FieldICareAbout )
 

looks at the contents of FieldICareAbout, then tries to to find a field so named in order to get its contents. See the Arrow/Target/Bullseye examples in the help.




GetFieldName ( TableICareAbout::FieldICareAbout )
 

returns the name of the referenced field as text, i.e. "TableICareAbout::FieldICareAbout". From this, it should be obvious that:




GetField ( GetFieldName ( TableICareAbout::FieldICareAbout ) ) 




is the same as:




GetField ( "TableICareAbout::FieldICareAbout" ) 




and very different from:




GetField ( TableICareAbout::FieldICareAbout ) 

Link to comment
Share on other sites

This topic is 4758 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.