1 2 Previous Next 20 Replies Latest reply on Jul 4, 2016 9:38 AM by alangodfrey

    Performing Find within Portal

    bengordon

      Hi,

       

      I am trying to perform a find within a portal and when I perform the find it does visibly perfofm any actions within the portal. What would be the best way to go about searching a portal to end up with a specific row selected after the find has been performed?

       

      Many thanks,

      Ben

        • 1. Re: Performing Find within Portal
          Mike_Mitchell

          Perform Find works in the context of the current layout. If you perform a Find using a related field in a portal, FileMaker will return all records in the current table that have the search term in any related field. (You may already know that.)

           

          In order to locate the specific related record, you will need to loop over the portal rows. Assuming you're doing this in a script, you might do something like this:

           

          Enter Find Mode [ ]

          Set Field [ yourRelatedTable::yourRelatedField ; Value: yourValue ]

          Set Error Capture [ On ]

          Perform Find [ ]

          If [ Get ( FoundCount ) < 1 ]

               {do error trapping stuff here}

          End If

          Go to Field [ yourRelatedTable::yourRelatedField ]

          Loop

               Exit Loop If [ yourRelatedTable::yourRelatedField = yourValue ]

               Go to Portal Row [ Next ; Exit after last ]

          End Loop

           

          HTH

           

          Mike

          2 of 2 people found this helpful
          • 2. Re: Performing Find within Portal
            bengordon

            Hi Mike,

             

            This appears to be working, although when I try and find a record it jumps to the bottom of the list of records and does not go to a record and jumps to the bottom of the list in the portal. Do you know what might be causing this?

             

            Many thanks,

            Ben

            • 3. Re: Performing Find within Portal
              Mike_Mitchell

              I don't even understand your question. What do you mean, "list of records"? What do you mean, "does not go to a record"? Where is this portal? What does your search consist of? How are you initiating it?

              • 4. Re: Performing Find within Portal
                Stigge

                What i think he is trying to say is that if he do a search.. and let say record 255 is the found record. the record 255 is showing in the bottom of the portal, not as active top row.

                 

                Reason am typing now is that i have the same issue that i been wrestling with for a while without really been able to solve it. =)

                • 5. Re: Performing Find within Portal
                  alangodfrey

                  Are you expecting to stay on the same (parent record) which has say 200 lines in a portal, and when you perform a 'Find' in the portal, you will only see listed those lines that match your search criterion?

                  • 6. Re: Performing Find within Portal
                    bengordon

                    That is close to what I am saying. What I would like to happen is when I put in my search term and click the "go" button for the script, then as Stigge said to have the row correct row appear at the top. An alternative would be only displaying the searched for record within the portal. I do not want to change layouts.

                    • 7. Re: Performing Find within Portal
                      alangodfrey

                      If you want to appear to be searching within the portal I would include a global field above the portal and allow the user to enter the 'search' criterion there.  Then change your portal to be filtered, and use the term in the global field to match the records you want to see displayed in the portal.

                      Note that you may need to trigger a refresh of the portal with your 'Go' button.

                      • 8. Re: Performing Find within Portal
                        bengordon

                        Would setting up the portal be as simple as saying that the "relatedtable::relatedfield = currenttable::globalvariable"?

                        • 9. Re: Performing Find within Portal
                          PeterDoern

                          If I understand correctly, perhaps you could do something like:

                           

                          1. when you land on the correct portal row, set variable $rowNumber = Get ( ActivePortalRowNumber )

                          2. Go to Portal Row ( $rowNumber + <number of rows in the portal> )... will force the portal to scroll up

                          3. Go to Portal Row ( $rowNumber)

                           

                          Naturally, this depends on the number of portal rows being constant and will fail if your portal is set to resize. However, you could probably calculate the number of visible portal rows using GetLayoutObjectAttribute ( <portal object name> ; bounds ) and the height of the portal row.

                           

                          Also, if the "found" portal row is near the bottom of the list of portal rows it will appear near the bottom of the portal regardless.... there's no way to scroll beyond the last portal row.

                          • 10. Re: Performing Find within Portal
                            alangodfrey

                            If that's what you want, yes.  That will show only exact matches.

                            It depends what you want the user to see.  Sometimes we use that technique with PatternCount, and also with a diminishing list, and sometimes with several 'words', so the user can search for things they might not be too sure about.

                            If you will always have an exact match I would use your suggestion.

                            If you want the user to be able to gradually narrow down their 'search' then use a more complex technique.

                            • 11. Re: Performing Find within Portal
                              bengordon

                              I like the idea of not having to be an "exact" match where the only record that appears is a perfect match. What would be the method for gradually narrowing down the shown records.

                               

                              For instance, as the user types more letters of a name the list of names shown changes as the user is typing.

                              • 13. Re: Performing Find within Portal
                                Mike_Mitchell

                                I try to avoid filtered portals, as they perform poorly over the WAN and as record counts increase. You can use the inexact match with a combination of ExecuteSQL and a global field in a dedicated relationship. Something like this:

                                 

                                1) Create a global field for storing a list of keys.

                                 

                                2) Modify your relationship (or create a new one) to include that global field on the parent side, pointing to the ID field in the child table, plus the regular key field.

                                 

                                3) Write a script that sets the global field to the list of keys matching what the user types. Something like:

                                 

                                     Commit Record / Request [ ]

                                     Set Variable [ $sqlQuery ; Value: "SELECT child.id_Field FROM child WHERE child.searchField LIKE '%'" & searchTerm & "'%'" ]

                                     Set Field [ myTable::globalJoinField ; Value: ExecuteSQL ( $sqlQuery ; "" ; "¶" )]

                                     Commit Record / Request [ ]

                                     Refresh Window [ ]

                                 

                                You can do the dwindling list technique Alan mentions by using a Script Trigger, but if you do, then you'll probably want to use a more sophisticated script and put a timer into it to avoid the user suffering a delay as it periodically evaluates on every keystroke.

                                 

                                Mike

                                • 14. Re: Performing Find within Portal
                                  alangodfrey

                                  In principle, (and it depends slightly on which FM version you are using):

                                  - create the global field

                                  - set the filter to match the global with the PatternCount in the field you are 'searching' in

                                  - create a script, triggered by OnObjectModify on the global so that it commits the field, refreshes the portal, and returns to the global field.

                                  - the user just types and sees the portal diminish as they go.  Depending on the record count in the portal there may be a delay.

                                  - you can refine the filter criteria to check for say a match of the start of the field (intuitively users tend to start typing the start of the name), or make it that they can type any letters (they may not know whether the drug is 'paracetamol' or 'parecetamol', but they know it ends in 'cetamol'), or they can enter several 'words', so they can type 'para' 'mol' and '50' and it will show only drugs containing all of those letter patterns.

                                   

                                  Those are just examples - which is best depends on the way the user interacts with the portal.

                                  1 2 Previous Next