5 Replies Latest reply on May 26, 2014 6:21 AM by sedona_1

    Issue with Quick Find in Popover



      Issue with Quick Find in Popover


           I created a popover that contains a global field called x_quickFind. The popover itself has an OnObjectEnter script trigger that goes to that field, and the field has an OnObjectExit trigger that runs my quick find script (see screenshot). So far, I've placed this feature on two layouts - a form view and a list view. Neither one of those layouts contains fields that allow entry in browse mode. Everything works great except for one relatively small issue that's driving me crazy!

           As you can see in the script, when only one record is found, I have it displayed on the form layout, and when there are multiple results, they're displayed on the list layout. After the find has been performed, I want the popover closed, but whenever the results are displayed on the same layout where the find was initiated, the popover stays open. If the results are displayed in the other layout, it works the way I want.  In other words, I can run the quick find on the form layout, and when there are multiple results, they're displayed on the list layout - where the popover is closed. But if I do the same thing, and there's only one record in the results, I stay on the form layout, and the popover remains open.

           Attempts to solve the problem:

           In the script, you'll see where I've got 3 Close Popover steps. They were my initial attempts to solve the problem, but they're not working. I tried moving the last Close Popover step in between the two End If steps, but that didn't work either. Based on a post I found in this forum, I also tried adding a Commit Records/Requests step after the Close Popover steps - still no luck.

           Interestingly, I found several posts that refer to problems with keeping a popover open, but it appears that I have the opposite issue. Based on one of those posts, however, I tried this: Since I don't have any custom graphics or anything on the popover button, I applied an object name to it, and then added a Go to Object step at the end of script to place focus back on that popover button. I thought that might make it act as a toggle and, therefore, close the popover, but that didn't work either.

           Based on another post, I got the idea to add a step that goes to another layout and then returns. I could probably set another variable at the start of the script that captures the name of the current layout. I'm not really sure where (within the script) I'd place the steps to go to the other layout and then return, though. Besides, it seems like an awful lot of steps just to close a popover!

           I feel as though I'm missing something obvious, and I don't want to mess too much with the script, because aside from this small issue, it works great. If necessary, users will just have to get used to closing the popover manually when it stays open, but I'd really like it to happen automatically, so any suggestions will be appreciated.

           Thanks so much!


        • 1. Re: Issue with Quick Find in Popover

                    either one of those layouts contains fields that allow entry in browse mode.

               Is the culprit here, I believe. I ran a version of your script in FileMaker Advanced and used the script debugger to watch things take place step by step. When you are already on the Form layout and find just one record, the script closes the popover but then, because it's a form view, FileMaker tries to put the cursor into a field for you. Since the global field inside the popover is the only one that allows access, FileMaker puts the focus back into the global fields and re-opens the popover. In the debugger you can watch the script close the popover only to see the popover pop back open after the script terminates.

               I found two ways to keep the popover closed:

               Add a commit records steps AFTER the close Popover step.

               Or add a field to the layout that permits browse mode access.

               I'm not sure if the popover re-opening like this would be considered a bug if reported to FileMaker in Report an Issue or not. It seems inconsistent with what you get with list view.

               And that gave me a third way to keep it closed: Add steps that change the view to list and then back to form.

          • 2. Re: Issue with Quick Find in Popover

                 Thanks so much for your prompt response, Phil!

                 I tried adding the Commit Records/Requests step after the Close Popover, but that didn't seem to work. As for switching from "view as list" to "view as form", if I have the form layout limited to only view as form (in Layout Setup dialog), and the list layout to view as list, would that still work?

                 I especially like your idea of adding a field to layout that permits access in browse mode. Ideally, though, I'd like it to be hidden from users. Would it be possible to put it to the right of the explicit layout width? Or maybe putting something up in a corner or somewhere and sending it to the back?



            • 3. Re: Issue with Quick Find in Popover

                   Commit records is by far the simplest solution. It worked for me when I tested this. If it doesn't for you, I suspect that your script may be tripping another script trigger that you have set on some part of your layout. I'd look for and deal with that issue before trying the added field technique. I didn't try placing the field to the right of the layout boundary, but you can try it for yourself to see if that works. You might also try setting its "hide when" setting to True to place it on the layout, but leave it invisible and inaccessible.

                   If you test those ideas, please report back with your findings.

              • 4. Re: Issue with Quick Find in Popover

                     I think you're right about another trigger being tripped.  I have to go out of town on business for the rest of the week, but I'll investigate that, as well as try your other suggestions, as soon as I get back on Friday.  I'll let you know what happens and what I end up doing.

                     Thanks again!

                • 5. Re: Issue with Quick Find in Popover

                       The first thing I did was add a Commit Records step after each of the 3 Close Popover steps in the script. With the debugger open, I watched it, and it seemed to work ok until I reached the last Close Popover and Commit Records. So, I disabled those two steps at the end of the script and ran it again, but the popover stayed open.

                       At that point, I was really expecting to find a layout trigger that's causing the problem. I don't have any layout triggers at all on my form view, however, and I've got an OnLayoutEnter trigger on the list layout that simply sorts the records by the break field, so I doubt that would have anything to do with it.

                       I created a global text field called x_global, placed it directly on the layout, and specified "true" as its "hide when" setting. At the end of the script, I added a Go to Field step that places focus in that global and followed it with a final Commit Records. Still no luck.

                       I've got two object triggers, though, and I suspect one or the other is the culprit. The popover itself (the frame) has an OnObjectEnter which runs a script that places focus in the x_quickFind global field (so users can start typing their criteria right away, without having to click into the field). The x_quickFind field has an OnObjectExit trigger that runs my quick find script.

                       I keep thinking that the OnObjectEnter trigger on the popover frame is somehow causing the issue, but I don't really like the idea of removing it. So...at this point, I'll probably just get used to having to close the popover manually. I really appreciate your help, Phil, and your suggestions have taught me more about FileMaker - which is a GOOD thing!

                       Thanks so much!