Woodnote Posted March 18, 2011 Posted March 18, 2011 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!
comment Posted March 18, 2011 Posted March 18, 2011 Have you also looked at: http://fmforums.com/forum/topic/76514-validate-date-time-or-timestamp/page__p__362286#entry362286
Woodnote Posted March 18, 2011 Author Posted March 18, 2011 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!
comment Posted March 18, 2011 Posted March 18, 2011 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).
Woodnote Posted March 19, 2011 Author Posted March 19, 2011 You can use the Set Field By Name[] step to avoid hard-coding the field to be searched. This is amazing. Seriously, I just did a google search and came up with a ton of amazing articles about this...thanks so much!
comment Posted March 19, 2011 Posted March 19, 2011 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 )
Recommended Posts
This topic is 4998 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 accountSign in
Already have an account? Sign in here.
Sign In Now