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!