Parsing Text / New Requests Script
Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com’s entire library of video tutorials.
Learn More
Subtitles of the Movie
Now we're ready to examine the script that will transform the items checked in this check box into new Find Requests. But before we start that we need to modify the cancel button that we copied from the Customer's Find layout. The continue button's fine, but the cancel needs to be modified. So we'll go into ScriptMaker and we'll come down here to cancel and you see it's already been modified and I'll highlight the steps that were there before we modified it. So, essentially we added an If Statement that says, If the Get Script parameter equals quote new window quote, close the window, otherwise go to the last layout. So the idea here is we're going to open up a new window on top of our Customer's Layout that goes to this particular customer's request layout and we're going to make it real small and you'll see how it works and that's why we want to close the window. And I could have written another cancel script, but I'd like to unclutter ScriptMaker and so putting this all into one script it really is pretty easy and I'm probably going to have other scripts that we'll need to close the window versus going last layout and this just all makes sense for me. It's very easy to program. Why have two scripts when you can have one? So we'll close this and we'll move on to the button because there is some definition on the button that you need to do. So we'll come in there, double-click on this, make sure we double-click on the actual button, and you'll see that we have the Optional Script parameter of quote new window quote. You need to make sure you pass that along so that this cancel button runs the first part of the If statement and if it doesn't have it, it does the Else and goes to the last layout. So now we'll go into ScriptMaker and we'll go find our Find Category Script and the first thing we do is our standard stuff, Allow User Aborts, Set Error Capture, we initialize X Category so no options are checked and then we create a new window. And we name that window Find Category, and we could do some changing of the layout size. Remember we have a smaller layout that we're going to look at. But there's actually an easier way to do it. We don't necessarily need to do it here. So we're going to say, Go to that Request layout and then resize to fit. So again we could have done the same thing here but it would have been very tedious figuring out the numbers. Here, this option just resizes the window to fit to the last object on the right and the last part on the bottom. And then we can follow that up with centering that window. Here's how we center the window. We say, Get the Window Desktop height. That means if we have a window this size this, this from here down to here, in other words, a whole window size, that's the desktop height. We subtract that from the window height. Let's say this is your current window right here, and what that gives us is the distance from here to here, and from here to here. And if we divide that by two then we know how far down from the top we need to put the top of the window to make it perfectly centered; and the same thing with the width. Get Window Desktop width minus Get Window width divided by two and then we'll have a perfectly centered window. We then pause, because then we're going to let the person do their checks, because they're going to be on the right layout, check those options. We immediately close the window after they do that, enter Find Mode and here is where the magic happens. Everything before this was really interface, here's where the real technique comes in. We go into a loop and we're going to Set Field Exit Loop and Create New Record Request, and actually we'll be in Find, but this will be a request. So, the first time we go into Find, but we already have a find request, we don't need to create one, so we're going to start off with our Set Field, we're going to specify the Category Field, that's where we want to put our Find criteria into, but we want to get all that from X Category, but remember that as we check multiple items from the X Category check box they were held in return separated lists. Well you can use the function called Get Value to grab a specific value out of that return separated list. If I listed one, well, it would give me the first value; two would give me the second value. And the way we provide that number is by looking at how many requests we have. The first time we're in the loop we're going to have one request. If we loop again we'll have two, and so that will increase this and change this formula so that we keep going down the list and grabbing the first value, the second value, the third value, and so on until we decide to exit, and we exit when the request count equals the number of values in X Category, in other words it counts the number of values or value separatable returns inside the X Category field. When those equal each other we know we've gone through that whole list and we can exit and not make another new record request. Then we're ready to perform the find and it is possible that there will be no records found, so we check for 401, show an appropriate message with one button choice. You can go back to previous sections about the Ultimate Find and find out what we can do as far, as making other choices here, and instead of Show All Records we could use the Save Table Occurrence technique to have put us back in the right Found set, we're not going to do that right here. We're just trying to focus in on what we need to get this job done. So if there are records found, it's going to come down here and say, If found count is one go to Form View, otherwise go to List View. So, let's give this a try and see how it works. We'll go over to our Customer's form, go into Browse Mode and you see I already have a nice little icon here for the find. All I did was take a snapshot, a screenshot, of this little find icon here, cleaned it up a little bit, and then added on the button here and attached the script that we want to run. That's it. So, we click this, you notice it comes up here right in the center which is real nice. We checked the options we want, click Continue, it gives us a list, but let's see what it did. We can go in here and Modify Last Find and see that we have three requests. The first one is Commercial, the next one is Government; next one is Nonprofit. So, don't just look at the records and check the data. Look at the modified last find so you can make sure that it actually put in what you expected it to put.
Tutorial Information
| Course: | FileMaker Pro 9: Advanced |
| Author: | John Mark Osborne |
| SKU: | 33824 |
| ISBN: | 1-934743-32-1 |
| Release Date: | 2007-11-21 |
| Duration: | 10 hrs / 115 lessons |
| Work Files: |
Yes |
| Captions: | For Online University members only |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |
VTC Sign up & Benefits
- Unlimited Access
- 98,729 Video Tutorials (23,265 free)
- Video Available as Flash or QuickTime
- Over 1026 Courses
- $30 for One Month Access
- Multi-User Discounts Available
United States 