Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
After you've established some table relationships inside your FileMaker file, you can start benefiting from some of the relationship-based functionality. We've already discussed in previous movies in this chapter the ability to use related fields in your layouts, which are basically borrowing the field values from the parent tables. And you see here in this layout, we've already discussed how we can add portals, a layout object that allows you to see related child records and your parent record. And now I'm going to actually show you how relationships can affect scripts. In particular, there is really handy script step that I want to show that's called Go to Related Records.
So what we're going to do in this example is place a button for this script on the Customer record that a user can click on and what it will do is pop up a new window that will display all of the related invoice records in a list that can be printed and all this can be done in one simple script step. So first let's go into Layout mode and let's draw a new button. And let's pick Go to Related Record.
And if you go and hit the Specify button, you're going to see that the window "Go to Related Record" Options appears. Now the Go to Related Record does exactly what it says. What we're actually looking at when we're viewing this layout is a customer and that customer's related invoice records. So essentially what we're going to do in this script is go to these related records, which means go to the table they're based on, create a found set with just these related records, and go to a layout that's based on that table. And this is a pretty handy trick because you might want to print these, or you might want to do something with them in another script or whatever it might be, but it does a couple of things in once.
It navigates to the proper table and layout, and it creates a found set for you. It's a pretty handy tool. So all you have to do is make a couple of decisions here. First, you'll see we want to show related records from. And when you choose Get related records from, what you're really saying here is, what records do you want to display in this new window or what records do you want to navigate to? And so what we're doing is navigating from the parent to the child. So really what we want to do here is see the Invoices. And here it allows us to show all the records in a layout and we're going to click on this and we're going to say, we want to see all these records in a layout that's based on invoices. So let's take Invoice List.
That way all the fields that we need are already going to be there. And also to hear something new that we haven't talked about yet in this title but the concept of a new window. FileMaker allows you to create a new window, and you can do so in any layout underneath the Window menu. Simply hitting New Window will pop up an exact copy of the window you are just in. But in this case we can click the button and specify some settings for the new window. And what it will do is pop up a new window based on the height and size that we're talking about here.
And also we can put a name in the title bar there. So I'm going to say "Invoice Items". And if hit Specify, you see I can bring this into a calculation. So let's combine some text in the field "Invoice Items for " and then of course and if we want to connect text to the field there a function and a Calculation dialog we have to use ampersand, and we'll pick the CompanyName. I'm going to say OK.
And now we can say the height of the window and the width of the window. Now we want this window to be a little smaller than the window on the background. So let's say the height will be 700x500 pixels. And that's just a guess. You can experiment with a different window sizes in Layout mode and come up with one that you like the best. And we're going to leave these options alone. Basically, this tells us how far from the corner we can space everything. We'll hit OK. And now the last decision that we're going to make here is whether or not we want to show only the related records, because right now all it will do is pop up a new window, navigate to the Invoices List, and show us all the Invoice records.
But what we want to see is only this customer's related records. So we'll say Show only related records. Now you can also choose to show all the related records for just the record that you are on at the time or if you choose this, it'll show all the related records for every parent record in your found set. So if you have a hundred customers chosen when you hit this button, it'll show you all of the invoices related to all hundred of those records. But in this case we just want one. So we'll hit OK and we're going to hit OK again, and we're going to call it Go to, let's say, Invoices.
All right, save that. Go into Browse mode. And let's see what happens. So here we've got two records. Let's hit Go to Invoices, and there we have a new window that's popped up and we can position that around if we want, but notice now if we close that window, I can say Go to Invoices. And now an Invoice window pops up that has all of this customer's related records and the customers name and all sorts of interesting info here as well as the Summary value, because here I'm just using the same layout we set up for the subsummary report back in the subsummary report chapter.
But because there's only one customer it just groups one group. But it still gives us the summaries. So I would strongly recommend that you use this for if you want to print the items in a portal. As a matter of fact, I'm going to so far as to say you should never print a portal. The main reason is because you never know how many rows you're going to need. So, for example, if I printed this portal, that's fine. There are only two records in it and same with this one's only got one. But if I print this portal then I'm going to miss out on all the data that shows up below the fold, so to speak.
So it's really just poor practice, and you don't want to have to create a portal that's so large that it would accommodate even the most massive amount of related records. Instead, just simply navigate to a layout that's based on-- simply navigate to a layout that's based on the child table and list every one of the related records and print them here. Because when you print a list view FileMaker takes care of things like page breaks, and it'll print as many pages as you need. It's a much more effective process.
And also we can change this, applying new relationships if we'd like to. For example, if we double-click on this and hit Specify and then instead say Invoices Shipped, we can then pick a Layout > Invoice List, leave everything else the same, hit OK, hit OK, and we can change this to Shipped, or we could have buttons for every status here if we want. Back in Browse mode, we hit Save, and now we hit Go to Shipped Invoices, and now we only see three.
Pretty cool stuff there! See that's the same for the next record of course. Go to Shipped Invoices, which combines our filtered multipredicate relationship along with a Go to Related Records script step. So there is a bunch of interesting things that you can do with navigating users to other layouts once you've established relationships between the tables. Allowing your users to print the contents of the portal without having to print the portal itself is just one of them.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.