14 Replies Latest reply on Jun 12, 2017 8:20 PM by beverly

    Perform QuickFInd Script Step - with asterisks?

    wendy

      I have created a quickfind field on a layout. It's a global field, and uses a script with the Perform Quickfind script step. (Also using script triggers.) It works beautifully. Except I just discovered that I can search for:

       

      C1-194 ...and the appropriate records are found: those with C1-194 in any field.

      But if I search for 194, records with C1-194 in any field are not found.

       

      I can find C3-506-V1, but not records with 506. (It will, of course, find records starting with C3.)

       

      I figured I need asterisks.

       

      But typing *194* into my field does not work, nor does adding concatenated asterisks within the script. I tried some other [very] long shots without success.

       

      Users will often want to search for "root" numbers such as 194 and 506.

       

      I'm out of ideas. It's probably either something very simple that I've overlooked, or the Perform Quickfind script step will not allow search with wildcards. I hope not, as otherwise this is a fantastic solution for us that eliminates a lot of development work.

       

      FMPro/Advanced 13 on both Mac OS10.9.5 and Windows 7 Enterprise. We have FMS13 on Mac OS10.9.5, but I've tested with both a local file on my desktop and the served file.

       

      Thank you.

        • 1. Re: Perform QuickFInd Script Step - with asterisks?
          SteveMartino

          Instead of quick find, just do a script with a regular find and you may be able to avoid the wildcards all together, unless you really need to narrow down your search

           

          Allow User Abort [Off]

          Set Error Capture [On]

          Set Variable [$QF; Value: Table::global field]

          Enter Find Mode [ ] //uncheck pause

          Set field [field you want to search; $QF]

          Perform Find

          If [Get(LastError)]

              Show Custom Dialog ["No Matching Records"; "No records match the search criteria."]

          End If

           

          If you want to search multiple fields, do an 'or' Search:

           

          Allow User Abort [Off]

          Set Error Capture [On]

          Set Variable [$QF; Value: Table::global field]

          Enter Find Mode [ ] //uncheck pause

          Set field [field you want to search; $QF]

          New Record/Request

          Set field [second field you want to search; $QF]

                ...repeat the previous 2 steps for as many fields as you want to search...

          Perform Find

          If [Get(LastError)]

              Show Custom Dialog ["No Matching Records"; "No records match the search criteria."]

          End If

          • 2. Re: Perform QuickFInd Script Step - with asterisks?
            Extensitech

            Long shot, but is it possible that you've made your part "number" field instead of a text field? Since it may include letters, characters, etc., it should be a text field. Perhaps it already is, but if it were a number field I believe that would cause the results you're describing.

             

            Chris Cain

            Extensitech

            1 of 1 people found this helpful
            • 4. Re: Perform QuickFInd Script Step - with asterisks?
              user19752

              As "will often want to search", you may be better to make calculation field for "root" numbers as indexed, to search "quick".

              • 5. Re: Perform QuickFInd Script Step - with asterisks?
                wendy

                Thanks, all, for the input.

                 

                Extensitech, the field I mentioned is indeed a text field.

                 

                I'm disappointed, as I was hoping to transfer this approach to other areas of our database without a lot of tweaking for each situation. It's an inherited legacy database with well over a dozen files and prolific layouts. Depending on the situation, a single find might involve quite a few fields.

                 

                It seems an odd limitation that the QuickFind step doesn't support asterisks. In my experience users often want to search multiple fields because they're working with less than optimal input data and/or complex requests. We're used to OS-level find features that have broader search abilities when needed.

                 

                (And unfortunately, since our full-time administrator retired the programming duties were added to my existing job description, so I'm always hoping for max time efficiency. A complete database overhaul isn't unreasonable, but it's not realistic at this time.)

                 

                I'll look at using a calculation field for just root numbers searches, but given the variations in where the root appears in the overall "number", this may be difficult. SteveMartino, thanks for the detail in your reply, as I'll likely be headed down that path also.

                • 6. Re: Perform QuickFInd Script Step - with asterisks?
                  siplus

                  Let's say that your QuickFind field is a serial number, call it "Serial".

                   

                  In your specific case you can create a calc field, SerialCalc, = Substitute(Serial; "-";¶).

                   

                  You will enable QuickFind only on SerialCalc.

                   

                  Then you will be able to QuickFind on C3 or on 506 or on V1.

                   

                  503 V2   (values separated by space) will also work in QuickFind, performing an and search.

                   

                  50 V will also work, no need for asterisks, will find c1-507-V5 and also d7-504-v1.

                  • 7. Re: Perform QuickFInd Script Step - with asterisks?
                    wendy

                    siplus, I'm not sure I follow.  I do need to search multiple fields on a layout--and other layouts in other files with other fields with similar mixed data. Another example would be searching all fields on a layout for 9538422 and having it bring up a record with ABC9538422. Hence my attempt at using the Quickfind step. I'd hoped that I could just copy and paste my field and scripts without much rework.

                     

                    FWIW, this is what I did originally:

                    • Created the global Quickfind field;
                    • Gave it rounded corners and a white background;
                    • Built a magnifying glass using Filemaker drawing tools (circle and line grouped) and placed it just inside the field (screen capture attached);
                    • Set field padding on the left to 15, added an inner drop shadow with a blur of one;
                    • On the Inspector/Data tab, in the "go to next object using" area, checked Return and Enter;
                    • Added two scripts and script triggers:
                    •   OnObjectEnter:  A "Quickfind_Clear" script that just sets the field to ""
                    •   OnObjectExit: A "Quickfind_Find" script:
                    •   If (not IsEmpty (MyTable::YourQFfield)
                    •       Perform Quick Find (MyTable::YourQFfield)
                    •   End If
                    •   Exit Script [Result:  0]      (false)            (Thanks to Bruce Herbach, 2/15/2015, "Exit Field Focus" thread)
                    • I already had an OnLastWindowClose script for the file (we have a multi-file database). I added a step to clear the QuickFind field. Could also add a trigger when the user leaves the layout.

                     

                    Resulting behavior:

                    When I click in the field, the magnifying glass disappears and a blinking cursor shows.

                    I type in my search criteria and press the Enter/Return key on the keyboard.

                    It finds the records and exits the field.

                    The value I searched for remains in the field until I click in it again, at which point it clears for a new entry.

                    Right now if there is no match for the search criteria, it just shows the Filemaker default (No records match...)

                     

                    I can copy the field to various layouts with different fields without tweaking--except for the asterisks limitation.

                    I see from examples that I can set up finds to address specific issues in specific fields, but I was hoping to keep it simple.

                    • 8. Re: Perform QuickFInd Script Step - with asterisks?
                      siplus

                      QuickFind does a <searchstring>* find. It does not a *<searchstring>* find.

                       

                      And interface design will never make up for a lack of functionality. btw.

                      • 9. Re: Perform QuickFInd Script Step - with asterisks?
                        beverly

                        Wouldn't

                        something*

                        be the same as

                        something

                        (begins-with default)?

                        beverly

                        • 10. Re: Perform QuickFInd Script Step - with asterisks?
                          siplus

                          I explained the way QuickFind works, in terms used by the OP, which was concerned about wildcards ans specifically

                           

                          But typing *194* into my field does not work, nor does adding concatenated asterisks within the script. I tried some other [very] long shots without success.

                           

                          so I don't see the problem.

                           

                          Of course you don't have - and should not - use *.

                           

                          Good idea to post the official link to how quickfind works, btw.

                          • 11. Re: Perform QuickFInd Script Step - with asterisks?
                            wendy

                            I did view the link to performing a quick find in Browse mode, but it seemed to be discussing the "default" search box in the status toolbar, (which I'm keeping hidden) and I thought I could get around the search limitations if I built one on the layout instead and used the script step.

                             

                            Oh, I was just proud of my "paste on any layout and it works" programming, so I wanted it to be "perfect". Ego ego ego.

                             

                            Thanks, everyone.

                            • 12. Re: Perform QuickFInd Script Step - with asterisks?
                              kupietz

                              Late answer here, but for future thread visitors, are you developing on FileMaker Advanced? If so, why don't you modify an "explode" custom function to include substrings that don't start at the beginning of the input string, and put a hidden field on your layout that gives QuickFind access to it.

                              A "reverse explode" custom function would be:

                               

                              reverseExplode(theString)=
                              if ( length ( theString ) > 1,reverseExplode ( right ( theString,length ( theString ) - 1 ) ) & "¶" , "" ) & theString

                               

                               

                              This custom function returns reverseExplode("abcd") as "d¶cd¶bcd¶abcd". With a field containing this calculated result hidden on your layout somewhere, a QuickFind could find records with "abcd" even by searching for the string "bc".

                              • 13. Re: Perform QuickFInd Script Step - with asterisks?
                                kupietz

                                Note - I got a PM'ed question from a beginner who didn't understand how to add the custom function above to their database in FileMaker Pro Advanced. I've uploaded a working example at http://kupietz.com/offsite/reverseExplode_demo.fmp12 so beginners can open the Manage > Customer Functions... dialog and see how to use it.

                                • 14. Re: Perform QuickFInd Script Step - with asterisks?
                                  beverly

                                  Note: FMPAdvanced required to Manage Custom Functions.

                                   

                                  They can, however, be used if IN a file/database with FMPro (& FMGo & WD).

                                   

                                  Sent from miPhone

                                  1 of 1 people found this helpful