By Daniel Wood, 13 March 2017
Search is an integral part of any solution, and can take many forms. FileMaker provides us with a useful native find mode, along with quickfind. Often though this is unintuitive for users, or just does not fit in with the design of a solution. In this article we present a slick, great looking search box UI design pattern, and explain how it is built. We also incorporate a number of native FileMaker techniques to achieve this (no plugins here!).
The primary focus of this article is on the construction of the UI design for our search box. Other techniques discussed involve using relationship level filtering of results (in a basic way) and having a timed delay on our search filter.
So, what does FileMaker offer in the way of searching? Well there is find mode obviously. Great power, but perhaps a little unintuitive for the average user, especially in this day of age where websites provide pretty commonplace design patterns for searching. Quickfind is a much nicer alternative, combining an automated 'find mode' search of sorts, with a single search box making it easier for users to search.
Both find mode and quickfind rely on results being displayed in a found set. If your solution is setup this way then great, you can stop here :) If you are into building solutions that don't feel like native FileMaker, and feel more like a native application, then read on.
Portals have been used to display search results for a long time, it's no secret. No matter how you end up collating your results for display in a portal, the portal generally allows you to select a record to then navigate to. The benefit to portals is that they can be placed within a layout, for in-line results display. This is perfect for the modern solution where you may have a search box at the top of every screen.
The inspiration for this design was partly borrowed from websites and how they achieve search boxes. Two examples that come to mind are imdb.com and tv.com.
When you begin searching at imdb, matching results drop down underneath the search box. The size of the box shrinks or grows depending on the results found. If too many are found, a link at the bottom is provided to view the full results.
TV.com is also very similar. Results drop down displaying an image, information, and a few links to useful pages. The box resizes again depending on results found.
That was the goal. How close to this look and feel can we achieve in FileMaker natively. By that I mean no plugins, but I also mean no web viewers. I want this to be native to the point that making any changes to it's look and feel is achieved through using layout tools.
SO how did we do?
What you are seeing above is all native FileMaker. In order to make this usable on different layouts, it had to be easy to transport anywhere, and hook up for any given search box. A few points on this:
Pretty cool huh? We think so!
So what is actually going on here? Well, if you like to get stuck in and figure this out for yourself, there is a demo file at the bottom of this article you can grab and dissect til your hearts content. For those who would like a bit more information, read on.
Here is our search box setup in layout mode. We have numbered 6 key components to the search which we'll go through step by step to understand what they are and their role in creating the interface. Briefly what we have is:
And of course a portal to show the results.
We make use of the hide layout object condition to create the illusion of a box that shrinks in size as results are refined. Our lines are shown or hidden according to a set of rules to achieve this. The sliding panel is used to enclose all the objects we wish to hide en-masse (it's just an easy way to manage them).
Next we'll look at each object in a bit more depth.
The interface has a number of components, but two of them contain object names which are key. We use a naming convention for these:
There really isn't much to the search box. It's just a global field we placed on the layout to accept user input. We format it to look how we want.
The magic is applied to the search box through script triggers:
Quite a few aren't there? Fear not, only half of the triggers are concerning the user interface. The onObjectEnter and onObjectExit triggers are for deciding whether the results are to be shown or hidden. We always hide when the search box is exited, but we only show once the user begins typing. the onObjectKeystroke trigger is part responsible for searching, and part responsible for refresh of whether to show/hide results.
We will cover how the searching is done later on in the article.
While this isn't absolutely necessary, it's a really nice touch to tell the user how many results are found, and more specifically if nothing is found. We use a button bar so that we can place the calculation for display direct on the layout in this object.
We won't bother showing that calculation here, you can check it out for yourself in the demo. Basically it looks at how many records are found through the relationship to our results, and displays a text string based on that number, pretty simple stuff.
Now things get interesting! Our interface has 3 key horizontal lines which we'll call top, middle and bottom. The purpose behind all three is to show one of the 3 at any given point in time, hiding the other 2. The lines act as the bottom of the results box. There are three scenarios for when these lines show.
In the case of our top line, this will act as the bottom of our results box if there are NO results. In this case, we just show the "no results found" display text, and our box ends there.
So conversely we hide this line when there ARE results.
So now that we know our lines are to show the bottom of the box, can you think of when we would have this middle line act as the bottom of the box? I'll give you a clue, this line sits within a portal row at the bottom of the row.
Got it yet? How about if we only had 3 results found? Or 2? or 1? yes! This line is used as the bottom of our box when we have fewer results found than the number of default rows of our portal.
In our demo file, our portal is setup to show 7 rows. If we only find 3 results, then we want the bottom of our box to end at the bottom of the third row.
So, our rule for this line is that it is to be shown if there are results found, and where there are fewer results than our portal default. Or the converse of this: We hide it when the results are more than the number of portal rows.
Because this line sits inside the portal, we don't need to bother with the condition of whether there are results or not, this is going to be hidden if there are no results. However it will display on every portal row for which we have results, hence we must hide it on all bar one.
Ok so hopefully with top and middle out of the way, the reason for the bottom line should be obvious. If we have lots of results (more than the number of portal rows by default) then we want the results box to be the bottom of the portal. So this line sits just underneath the bottom of the portal.
If there are more results found than the portals default, we show this line, otherwise we hide it.
This is a transparent, no bordered single panel control. We use this so that we can enclose everything else inside it, and then we can just apply a single hide condition to the panel to show/hide everything inside.
The design for our results panel dictates that if the user is not inside the search box, then we will not show any results display. If the user is inside the search box, we only show results content if they have typed at least one character, otherwise we show nothing.
Showing or Hiding of the results panel is done by way of scripts that execute when the user both exits and enters the search field. Recall our panel has an object name, so showing/hiding of this is performed by simply refreshing the panel object (which triggers it's hide condition to run).
Good! We're almost there. Hopefully you can follow the reason behind the design components and why we show/hide certain elements under certain conditions. But how do we hide things?
We wanted this solution to be completely transportable and applicable to any other search box in your solution with as minimal effort as possible. To that end, we built a custom function in which all logic for showing/hiding UI components is contained.
This is our custom function called @SEARCH_ShowHide. The function takes 4 parameters:
When we setup a hide condition on one of our 4 main hiding elements, we simply reference this custom function. Here is an example of the hide condition on the middle horizontal line:
@SEARCH_ShowHide ( "search" ; "line_middle" ; 7 ; Interface_CUSTOMERS__results::id_customer )
We have told it the name of our search box, what component we are hiding, how many portal rows we have for results, and what the results primary key is.
We're not going to post all the code for the custom function here, you can look for yourself within the Demo File, but we'll point out a couple of things:
Here's what is going on:
When you put it like that it's really quite simple. There are a number of components but on their own they're all pretty simple and easy to see what role they play.
Building this into your own solution is simple. If you already have results being shown in a portal, then you're all set. Just paste into your solution and change the following:
This demo file has used filtering of results at the relationship level, and we do not use portal filtering. Digital Fusion has always had a policy of using relationship filtering where possible due to substantial performance gains to be had when working with larger data sets.
That is not to say portal filtering is bad, nor we never use it. For this demo, if you wish to use portal filtering then you will need to make a few modifications to the solution. Our demo checks the number of records found through the relationship to determine the number of results, and apply hide conditions accordingly.
The number of results found through portal filtering is a little different to obtain, as the relationship record count may differ from the portal record count. One technique you can use is to add a COUNT summary field to the results table, and place this inside the portal with an object name attached. You can then use GetLayoutObjectAttribute ( "ObjectName" ; "Content" ) to obtain the found count. This can be inserted into the hide custom function in place of where we count records found.
We won't go into much more detail into this here, suffice to say it is a change that can be made to use this technique with portal filtering.
Our search box uses script triggers to carry out when the reevaluation of the relationship occurs. This is a pretty common technique used to produce dynamic search results for years in FileMaker, ever since v10 introduced triggers.
We take this one step further. The traditional approach is to refresh search results after each keystroke. This can suffer from performance issues, specifically when there are many results found, or the user is over a WAN connection. THe user often finds themselves being unable to continue typing their search term while they wait for results to load. This can compound itself when results begin showing immediately after the first character is typed - as often the most results found are at this point in the process.
Our solution is to introduce a short timed delay before filtering occurs. We use an onTimer to control this delay. Every time the user enters a keystroke, we reset the onTimer which resets the delay. Once the user ceases typing, the delay occurs and after that the onTimer script runs, which carries out the search.
To give a basic illustration, consider the user typing the word "David" into a search box:
If the user stopped typing at the "V", then filtering would occur there. If they continued typing the rest of the word, filtering would again occur 0.5 seconds after the last "D" was entered.
We actually wrote an article on this technique a few years back now. You can read it here. The general techniques in that article are exactly the same as they are in our demo file now. In our current demo file we have simplified some things such as script parameters just to make this file easier to understand.
Because this technique uses an onLayoutKeystroke trigger after each keystroke, we can intercept certain characters and change the resulting behaviour. This is exactly what we have done when we detect the escape character is pressed by the user in the search field. In this case, we clear the search field contents. This is a nice intuitive way to clear the field rather than providing an X icon.
This is another one of those "many ways to skin a cat" things in FileMaker. Some prefer using portal filters, others relationship level filtering. At the relationship level, some build big keys, while others opt for exact matches.
Exact matches in this case are pretty useless, and keys that are built are often big and cumbersome.
A few years ago now, Danny Kohn on the webiste FileMakerInspirations.com wrote a very insightful article into this problem, and posed a technique using the ≤ and ≥ predicates of relationships, and the sort ordering of text in FileMaker to achieve a relationship filtering technique that results in a very lightweight key field.
You can read his article in full here. It covers the technique really well and so we won't go into much more detail on it in this article, suffice to say our demo file makes use of this technique.
What good is an article like this without a demo file to accompany it right? Well here it is! No username and password, fully unlocked just go for it.
Something to say? Post a comment...
Comments
dhinostroza 17/01/2024 2:25am (11 months ago)
Hi, Daniel,
There seems to be something missing in the demo file. The search field does display the list of contacts but, if you click on any contact name, nothing happens (i.e., you are not taken to the selected contact's page).
Best regards,
Daniel Wood 02/03/2020 12:23pm (5 years ago)
Hi Nick, thanks for the comment.
Firstly don't worry about sections as it's unrelated in the demo file to the technique at all, sections are purely for the demo files sections.
If you're seeing a full list of 163 features, and your search counter is incorrect, then the issue sounds more like with how you are doing the filtering in the relationship. Are you using a portal filter or are you achieving filtering of results through the way the demo does it, that being using search key calculation fields?
feel free to contact me at daniel@teamdf.com, it may be easier for me to see screenshots of your setup or a sample file, otherwise it's really just a bit of guesswork sorry.
Nick Hope 02/03/2020 6:34am (5 years ago)
Hi.
Ive been trying to implement this search into a database of software features, so my colleagues can search through it. I'll outline below relating my table names to the demo file.
I have three tables - feature details (eg Customer) , search (Interface), and feature section (Section). Trying to emulate the demo file with relationships also too.
I am at a point where I can a see a whole list of the features in the portal and I can type in the search field, however, it is only showing 1 result in calculation and the whole list of 163 features.
Any help from my description?
Cheers
Jim Cooper 16/10/2019 5:10pm (5 years ago)
Thanks for the reply.
I don't see any menus like "File Edit View Script ", or tool bars. I can't get to Manage Datebase or Script Work Space
Daniel Wood 07/10/2019 9:04am (5 years ago)
hi Jim.
The file is fully unlocked, and should automatically open for you with a full access account (username is admin, and no password). Once in, you should be able to access scripts/tables in the usual way - Scripts menu, or File -> Manage -> Database.
If they're greyed out, then check the permissions on the file and make sure you have read/write permissions on the file itself.
Jim Cooper 06/10/2019 3:33am (5 years ago)
Demo is great, but I can't find a way to see tables and scripts. Is it possible?
Weihao Ding 28/01/2018 5:29am (7 years ago)
Nice article. Very cool demo. I like the OnTimer technique a lot and highly recommend that to anyone building a solution that runs on WAN.
Damien Kelly 04/01/2018 11:04am (7 years ago)
I decided to revisit this, it's really cool, great stuff!
I added a subtle change, bolding matching text thats in the search field, in the portal results.
I used a custom function HiliteSingle > http://www.briandunning.com/cf/578 , I amended the custom function to return bold as well as colour.
Then I changed the portal field to a calculation, which uses the above custom function and the field that was in there, interface__CUSTOMERS__results::name .
Copy of the file is here in Dropbox > https://www.dropbox.com/s/df55nvzwyjmtzlf/ModernSearchUI_Bold.fmp12?dl=0
Damien
Daniel Wood 02/08/2017 4:45pm (7 years ago)
hi Joseph, thanks for the comment.
There really is no "easy" way to implement this specific technique. It comprises really two different techniques. The first is the interface side of presenting the search results to the user. This is basically what the article is detailing, how you go about it. To achieve this effect there are quite a few components to it, including as you mentioned a couple of custom functions, some script triggers, scripts, and layout elements which have various hide conditions on them and so on.
The other component is how the search actually operates and how you find records. We use keys & relationships to achieve this. How you do this is up to you as there are lots of ways to do this. You could script a quick find that collates a found set of results, grabs their IDs and uses those in the relationship. You could use a virtual list for this purpose too. You could just modify the way you use the relationship, you could also use portal level filtering. Applying a filter on the portal itself may prove easier for you to follow, but you need to consider it may not perform quite as fast over a wide area network.
If you are still struggling perhaps the easiest way would be to find a developer in your area, or on the internet who is able to assist you in implementing more advanced features and functionality.
Let me know if I can be of any more assistance, cheers!
Joseph San Laureano 02/08/2017 3:08pm (7 years ago)
Hi
I am a medical practitioner and beginner/early intermediate with filemaker.
I have created a solution to keep medical records and would very much like to implement this modern find UI technique but it looks like a lot of work in creating new tables with new fields, adding in custom functions etc etc.
How can I easily implement this technique?
Joseph
Daniel 26/06/2017 6:46am (8 years ago)
hi David, yes it could come close to being a substitute, there are pros and cons. The pro obviously being yes it would work across layout parts, however a few cons are the fact on Pro you cannot dismiss the card by clicking back on the parent window. You can close it all other ways, and one we've done a lot is a layoutkeystroke trigger to dismiss it on any keystroke (in this instance).
On Go it would be nicer given you can indeed dismiss by clicking back on the parent. On WebDirect it would not work and you'd need to stay with a panel.
I think you could simulate something almost identical, but not being able to close it with the mouse back on the parent window is a real limitation to it right now.
David Zakary 24/06/2017 6:03am (8 years ago)
Now that we've got FM16 with super-slick card windows, could a card be used instead of the slide panel? Wondering if this could get around some of the limitations of the header/navigation part and having the results show up in a list view?
Haven't tried it, just thought about it now as I'm integrating this into a system.
Daniel Wood 27/04/2017 10:37am (8 years ago)
Ah yes, very observant Mr Zakary :) I had come across this building the demo file, and figured I'd just leave it out ;) It is a bit of a nuisance for sure, and something that would be nice to have changed in future versions of FM. It's not ideal but you could place the sliding panel with the search results in the part underneath the top nav providing there is not too large of a gap under the search box.
David Zakary 27/04/2017 9:33am (8 years ago)
Another top notch demo Mr. Wood.
My only complaint, and this is a FM thing, not you - ideally the widget goes at the top of the layout - which might be a Top Navigation or Header part. The search results won't display across parts if that part is Top Navigation. It does work if it is a Header.
Daniel Wood 27/03/2017 10:55am (8 years ago)
hi John,
thanks for the comment!
In regards to the middle horizontal line. This is a line that is sitting inside the portal row. So this means without a hide condition on that line, you would see it appear on every portal row which is not ideal and not what we want to use it for. We want to use this middle horizontal line when we have fewer results found than the default number of rows that the portal displays. So if the portal shows 10 results, and we only have 5, then this is the time we want to show that middle horizontal line.
Again though, in this scenario above we only. want to show that line on one of the 5 results rows, in this case row #5 because this is the bottom of the results box. Rows 1-4 we do not wish to show the line.
Thus putting it all together the hide condition for this middle row is to HIDE it when either the number of results found is equal to or greater than the default visible rows, OR in the event the number of results is fewer, we want to HIDE it on every row that is not the last (so rows 1-4 hide, row 5 show..)
Hope that clears it up, using the word "bar" when talking about lines was probably a poor word choice!
John 27/03/2017 9:46am (8 years ago)
Daniel,
Great tutorial. Probably the best I have seen to date breaking out the individual elements and layers.
I have a question for you: At the *end* of the "Middle Horizontal Line" paragraph you say "However it will display on every portal row for which we have results, hence we must hide it on all bar one."
I am confused about what you mean by "...all bar one"
Thanks!
stryker 17/03/2017 7:39am (8 years ago)
nvm I think I may have figured it out. looking at the scripts now
cheers!
stryker 17/03/2017 7:23am (8 years ago)
Is anyone able to view this search bar under the hood? I cannot seem to edit the layout when opening the demo file.
John Mark Osborne 17/03/2017 6:49am (8 years ago)
Very nicely executed!
Daniel Wood 14/03/2017 3:49pm (8 years ago)
hi Shawn, thanks for the comment. Yes I've done a couple of solutions that have made use of selector connector as a means to provide a universal search context, big time saver for copy/pasting onto layouts. Other solutions the search box can be context dependent on the screen you are on, so horses for courses I guess :)
Shawn A. Krueger 14/03/2017 3:46pm (8 years ago)
Great stuff, as usual. Thanks for sharing!
Have you played with using this, combined with Selector Connector, to make your search results portal less context dependent? Could be a time saver if you are searching from multiple contexts.
Michael Sloper 14/03/2017 6:13am (8 years ago)
Great demo. I like your use of the install OnTimer for .4 with the modify trigger. Thats slick.
Hank Shrier 13/03/2017 4:36pm (8 years ago)
Great use of the whole FileMaker tool box. Gonna give it a try now.
Thanks
Daniel Wood 13/03/2017 3:44pm (8 years ago)
Thanks Denis, although I'm not sure about me doing much heavy lifting these days. This is the first article in 12 months. There are many others these days far more involved than me and doing far better work, Bruce is definitely one of them. Also Kevin Frank over at www.filemakerhacks.com is doing some really cool stuff.
Denis 13/03/2017 3:28pm (8 years ago)
Daniel,
Another great post - you & Bruce are doing the bulk of heavy lifting in the FM world outside of FMI these days. Keep up the great work!
1 2 next »
No one has commented on this page yet.
RSS feed for comments on this page | RSS feed for all comments