1 2 Previous Next 15 Replies Latest reply on Feb 16, 2012 12:02 PM by comment

    Capture Find Criteria when Error 401

    user12837

      I need a script which captures the criteria used for the previous Find when no results are found. For example,

       

      NameFirst = "Joe"

      City = "Ri"

       

      It would be easy if I could set variables equal to the values in the Find record fields rather than the current record in the underlying table before executing the Find. Is there a way to do that?

       

      Thanks,

       

      Tom

        • 1. Re: Capture Find Criteria when Error 401
          comment

          For what purpose?

          • 2. Re: Capture Find Criteria when Error 401
            user12837

            Suppose a script switches to find mode and prompts the user to type in a first and last name.  She enters

             

            NameFirst="Joe"

            NameLast="Smoe"

             

            and the result is a 401 error.  I want the script to pass the parameters

             

            "Joe"

            "Smoe"

             

            to a script in a different file which offers to create a record for Joe Smoe if the user provides additional information and clicks a button.

             

            (In a nutshell, I don't want the user to have to type "Joe" and  "Smoe" in twice.)

             

            Thanks,

             

            Tom

            • 3. Re: Capture Find Criteria when Error 401
              comment

              The best way to do that, IMHO, would be to prompt the user to type the first and last name into global fields. Then have the script enter find mode and use the globals to set up a find.

              • 4. Re: Capture Find Criteria when Error 401
                DavidZakary

                This shouldn't be difficult.

                 

                One method...

                Instead of peforming the search on the name fields (from your example) create a series of globals that match your fields. Have the script pause, the user enters their criteria and continues. Enter Find mode, copy the info from the globals into the corresponding fields and perform the find. If you get a 401 error you can then prompt to create the new record - this way you have the search criteria in the global fields to populate the new record with.

                 

                Just remember to clear all the globals before you run the script again.

                • 5. Re: Capture Find Criteria when Error 401
                  GordonShewach

                  Hi Tom,

                   

                  You can bring up the same find again using the Modify Last Find script step. Might that accomplish what you're trying to do?

                   

                  Alternatively, if it's a finite number of fields you're trying to capture info on and I assume the user is entering the find criteria (if the script entered it, you would already know what they are), you can do something like this:

                   

                  Enter Find Mode [Pause]

                  Set variable [$A; Value:TO::FieldName1]

                  Set variable [$B; Value:TO::FieldName2]

                  etc.

                  Perform Find []

                   

                  Gordon Shewach

                  Desktop Services

                  Ann Arbor, MI

                  • 6. Re: Capture Find Criteria when Error 401
                    deninger

                    Couldn't you store the values as local variables before doing the find, then catch the error with Get ( LastError ) and then if it =401 call a new script with the previously stored values as parameters?

                     

                    Not exact scipt syntax but hopefully illustrative:

                     

                    setVariable ($firstname ; field:firstname)

                    setVariable ($lastName; field:lastname)

                     

                    setErrorCapture (on)

                    performFind

                    setErrorCapture (off)

                     

                    if (get ( LastError) = 401)

                      performScript (createNewRecordScript ; $firstName ¶ $lastName)

                    end if

                     

                    where createNewRecordScript would retreive the values with the get (ScriptParameter) function

                    • 7. Re: Capture Find Criteria when Error 401
                      comment

                      deninger wrote:

                       


                      setVariable ($firstname ; field:firstname)

                      setVariable ($lastName; field:lastname)

                       

                       

                      That wil work if you know in advance which fields are being searched.

                      • 8. Re: Capture Find Criteria when Error 401
                        IreneVassos

                        __________

                             Suppose a script switches to find mode and prompts the user to type in a first and last name.  She enters

                         

                             NameFirst="Joe"

                             NameLast="Smoe"

                         

                             and the result is a 401 error.  I want the script to pass the parameters

                         

                             "Joe"

                             "Smoe"

                        _____

                         

                        Tom,

                         

                        What happens if the user only enters a find request for only one of the names? Do you still want to capture the query to pass the parameter if not found?  It would seem not, so then you would also need to exit the script before giving the option to create a new record/person, correct?  Just need some clairty.

                         

                        Irene

                        • 9. Re: Capture Find Criteria when Error 401
                          deninger

                          Of course you could always make this strategy more general, but it would take a bit more effort. In effect you could check all fields for input and store local variables that included the field name and contents (maybe as repititions like $fieldName[0] and $fieldContents[0]) and pass them to the resulting script to handle creatiion of a new record.

                           

                          Usually, though, the situation doesn't require this level of sophistication and can be handled with a much simplier script. My original interpretation of the question was "simpler" and not more general.

                          • 10. Re: Capture Find Criteria when Error 401
                            comment

                            deninger wrote:

                             

                            In effect you could check all fields for input

                             

                            That could be a problem, since "all fields" also includes related fields.

                             

                            Anyway, the point is that when in Find mode, the user can enter criteria into any field - even by mistake.

                            • 11. Re: Capture Find Criteria when Error 401
                              user12837

                              I could enter the Find criteria into global fields, and use those fields for the search.  But I was hoping for a more elegant method, such as

                               

                              Set variable [$A; Value:TO::FieldName1;Find]

                               

                              ... where the (nonexistant in FileMaker 11) underlined parameter would direct the function's attention to the Find criteria rather than to the values in whatever record happens to be current in the underlying table.  It seems odd that one can't do that, given Modify Last Find.  Obviously FileMaker remembers what those criteria are.

                               

                              Thanks to all,

                               

                              Tom

                              • 12. Re: Capture Find Criteria when Error 401
                                comment

                                user12837 wrote:

                                 

                                ... where the (nonexistant in FileMaker 11) underlined parameter would direct the function's attention to the Find criteria rather than to the values in whatever record happens to be current in the underlying table.

                                 

                                You can do that, after calling Modify Last Find. At this point, you'll be in Find mode and the values in fields are the search criteria.

                                • 13. Re: Capture Find Criteria when Error 401
                                  beverly

                                  I always like to do some basic FIND training in FileMaker. If your users have a multiple request find and/or use any of the symbols, getting them back with "modify last find" may be confusing.

                                   

                                  Otherwise the "modify last find" is the way to go, if they are making manual finds and get no records returned. You have to give them the knowledge on getting back to browse mode if they can't find what they want. That training helps them make the finds correctly, too.

                                   

                                  Beverly

                                   

                                   

                                  On 16 Feb 2012, at 12:13 PM, Michael Horak wrote in whole or in part:

                                  • 14. Re: Capture Find Criteria when Error 401
                                    user12837

                                    Hi Michael,

                                     

                                    >You can do that, after calling Modify Last Find. At this point, you'll be in Find mode and the values in fields are the search criteria.

                                     

                                    And so they are.  I'll be damned.  Never would have occurred to me in a million years.

                                     

                                    That's precisely what I needed, so

                                     

                                    Thanks much,

                                     

                                    Tom

                                    1 2 Previous Next