Script triggers have in many ways completely changed the game when it comes to Filemaker development. The fact that I can launch script triggers on mode changes opens up a whole slew of possibilities, one of which is being able to have a huge amount of control over where my users end up and what information they see while they are navigating my system. If I want to make sure that my users always have fields X, Y and Z regardless of how they get to find mode, I now have a way to make that happen.
##The Old Way
Pre-10, it was a little bit of a hassle to try to give users a customized find layout. For starters, it required scripting a method that would take the user to the correct find layout for their current context, making that process available on the main layout itself via a button and then locking down the permissions and changing the menu commands so that the users could only get to find mode via said button. It was doable, but kind of a headache. Now with script triggers, I can simply set a script to run when the user enters find mode that navigates them directly to the custom find layout I’ve built for them, and no matter how they get to find mode they will always end up looking at what I want them too.
##How It Works
The process of setting this up is pretty simple in and of itself. Let’s take a look at our starting point:
There is a pretty good amount of information being laid out for my users on this particular screen. Really they only ever search in about eight of these fields. The rest is just clutter when it comes to finds. So, I want to give them only what they need to see when they run a find.
To do that, I need to take three steps. The first step is to design my find layout, including only the fields that are essential for my users to find the data they need. Once I’ve got that done, I need to write a script to navigate to that layout. This can be a complex navigation script that tracks a history of visited layouts or a simple go to layout script step. Once I’ve got my script ready, I need to set the correct script trigger to make it run. The script trigger I’m interested in for this is called OnModeEnter, and you set it on the main detail layout that the users see (the one in the picture above for me). You can get to the layout script triggers on the last tab on the right in the Layout Setup dialog box. The OnModeEnter trigger runs whenever the modes you have selected are entered. So, to make sure that the user ends up on my find layout only when they are entering find mode and not at any other point, I deselect the “Browse” and “Preview” options. Now, this trigger will only run when the layout I’m on enters find mode, no matter how find mode is entered. So at this point, when my users try to search for an order they start at the screen above and are immidiately shuttled to the much more find friendly screen below:
Now my users are happy that they have a simple find screen to look at without all the exta clutter, and I no longer have to try to lock down my system of all it’s innate functionality to keep my users where I want them.
>Note: There is actually one final note to make all of this work seemlessly. Since you’ve taken your users away from the main detail page to set the find criteria, you should probably take them back once they actually preform the find. To do this, you’ll need to write one more script to navigate them back to the main detail page and set it with the OnModeEnter script trigger on the find layout to run when browse mode is entered. This will make sure that your users are taken back to the details page to view their results.