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.
Daniel,
Thanks for this technique and idea. Indeed it’s pretty powerful and can end up serving users better and more quickly than developers are served by some of the new additions to FM 10.
Daniel:
After scripted finds, I like to test which layout to return users to after a find. If there’s only one record, I show the original detail layout, but if there’s more than one I take them to a list view. That’s even cooler now that we have dynamic subsummaries. Thanks for the article.
Denis,
You are welcome! There is a lot of unexplored potential in the new features that 10 has to offer, so we hope to be throwing more ideas out there in the weeks ahead.
Susan,
That’s actually a great idea, and I’m stealing it and putting it into our template files. Thanks!
This is great. Honestly, I think I will stick to using Dialog boxes for my finds. I use both 24U SimpleDialog and Troi Dialog. This allows me to lock out and avoid the above pitfalls. I’ve been using this method for years. And it helps me avoid designing special layouts. Just my two cents.
I just with FM would improve the dialog box.
Excellent post and idea. Over the years, I’ve come to hate scripted finds and have come up with other methods to reduce the tediousness of creating find layouts, handling no records found and all that.
Using Script Triggers when mode changes streamlines this process, making better design available for those using the software.
Keep posting about FMP10. These are great ideas.
Thank you for this great tutorial!
I am working on Find Layouts and this report was really helpful!
I read the comments and what Susan has done is really interesting! Where can I find more details about “if statements” into scripted finds?
Many thanks!