1 2 Previous Next 19 Replies Latest reply on Sep 28, 2016 5:04 PM by fmpro_novice

    Loop through Quick Find

    fmpro_novice

      Can someone show me what a script would look like that would go through the records in each Quick Find set and perform the same script on each set of Found Records?

       

      Thank you.

        • 1. Re: Loop through Quick Find
          philmodjunk

          Can you describe what you want to do in more detail?

           

          A quick find as is the case for a conventional find only has one "Set of found records"?

           

          Do you want to loop through each individual record and perform a script with each?

           

          That can be done with this sort of script:

           

          Loop

            Perform Script [....

            Go to Record/request/page [next ; exit after last]

          End Looop

          • 2. Re: Loop through Quick Find
            fmpro_novice

            I have several sets of Records that are found based on my Quick Find criteria.

             

            I need a script that will loop through each Found Set and perform a script on each of the Found Sets.

            • 3. Re: Loop through Quick Find
              philmodjunk

              But you only get one found set at a time so how are you getting "several sets of Records"?

               

              Do you have a script that performs several quick finds in succession or are you doing something else?

              • 4. Re: Loop through Quick Find
                fmpro_novice

                In the setup for my database, I create a listing of sets of records. I have a dropdown that shows this list. I can select a set of records from this list, click Quick Find, and it will display only that Found Set.

                 

                I need a script that will select the first set of records, perform a script.

                Then, go to the next set of records, perform a script,

                then go to the next set of records, perform a script, then exit once all the Found Sets have had the script performed on it.

                • 5. Re: Loop through Quick Find
                  philmodjunk

                  Which means that you never have more than one found set at a time. It would appear that you need your script to loop through the values of that dropdown's value list performing the find followed by performing the script.

                   

                  For this example, I am assuming that you want to perform the same script with each set of records.

                   

                  Set Variable [$CriteriaList ; Value: ValueListItems ( Get ( FIleName ) ; "YourValueListNameHereInQuotes" ) ]

                  Set Error Capture [on]

                  Loop

                     Set Variable [$K ; $K + 1 ]

                     Exit Loop if [ $K > ValueCount ( $CriteriaList ) ]

                     Perform Quick Find [GetValue ( $CriteriaList ; $K ) ]

                     If [ Get ( LastError ) = 0 // records were found ]
                         Perform Script [....

                     End If

                  End Loop

                  • 6. Re: Loop through Quick Find
                    coherentkris

                    to expand on the previous suggestion from Phil

                    set var $finds" = list of finds

                    set var $counter = 1

                    set var $max = ValueCount ( $finds )

                    Loop

                       set var $find_item = GetValue ( $finds ; $counter)

                       Enter find mode

                       Perform find appropriate to the $find_item

                       Loop

                         Perform Script [....

                         Go to Record/request/page [next ; exit after last]

                       End Loop

                       set var $counter = $counter + 1

                       Exit Loop when $counter = $max

                    Loop

                     

                    You'll have to tweak the process so that finds are done right and that you account for behavior when no records are found.

                     

                    philmodjunk ill bet we find out the real requirements in the next reply.

                    • 7. Re: Loop through Quick Find
                      philmodjunk

                      but fmpro_novice specified using Quick find, not Perform find....

                      • 8. Re: Loop through Quick Find
                        coherentkris

                        you are correct about that .. my mistake

                        • 9. Re: Loop through Quick Find
                          fmpro_novice

                          In your line

                           

                          Set Variable [$K ; $K + 1 ]

                           

                          is the "$K + 1"   supposed to be the Value?

                          • 10. Re: Loop through Quick Find
                            fmpro_novice

                            Thanks, Phil. I believe I will have this working perfectly in just a few minutes.

                            • 11. Re: Loop through Quick Find
                              fmpro_novice

                              Well, I spoke too soon.

                               

                              Something not right is happening in this line of the script:

                               

                                 Perform Quick Find [GetValue ( $CriteriaList ; $K ) ]

                               

                              I'm not totally sure what this is supposed to do, but it Finds 4 records from different criteria in the list, performs the script, which then throws the rest of the script off.

                               

                              I disabled that line, then it didn't work at all.

                               

                              I went back and read your original response which said that my QuickFind only shows one set. Actually, the first list in the criteria is All. So, the "default" setting in the QuickFind is All which shows all the records. I wonder if this what is causing the script to fail. The loop should actually begin with the second criteria in the list.

                              • 12. Re: Loop through Quick Find
                                philmodjunk

                                Please note that this is the first time that you've specified what values are actually in that drop down.

                                 

                                I assumed values that you could manually enter into the Quick Find box--actual search criteria that you'd use for searching.

                                 

                                So the script is searching out records where one of the fields on the layout that are enabled for quick find has the word "all" in it.

                                 

                                How about describing exactly what values are in that drop down before we go any further?

                                • 13. Re: Loop through Quick Find
                                  fmpro_novice

                                  To establish the number of Found Sets, a number is chosen from a Drop List. Say for example, 3. Then a list is created: 

                                   

                                  All

                                  One

                                  Two

                                  Three

                                   

                                  When on the records layout, the default setting in the QuickFind list is All. Hence, all records are displayed.

                                  If I change the QuickFind dropdown to "One" then only the records in the Found Set One will display.

                                   

                                  So, I'm not totally sure what is being displayed in the Find in the loop because it displays records from a couple of the lists - not all of them - just a couple of them. It then runs the script across those records, which then makes the rest of the loop perform the script incorrectly.

                                   

                                  If I manually change the QuickFind to "One" - then run my script it works fine. Then manually change to Two and run the script, and Three run the script, it works fine. But when I run the script you showed me with script inserted in the correct place, it fails.

                                  • 14. Re: Loop through Quick Find
                                    philmodjunk

                                    Can't really see how that is supposed to work.

                                     

                                    What defines which records will be in the found set when "one", "two" or "three" are selected?

                                     

                                    Is it possible that you are referring to SAVED finds instead of QUICK finds?

                                    1 2 Previous Next