Security / Discount Override
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
We're ready to take a look at a pretty complex script for applying discounts, but before we take a look at it and analyze it, let's see how it works in action. This'll help you understand what we're covering in the script steps so you can equate it to what happens in the interface. So if somebody comes and clicks on the second row and wants to give a discount and they accidentally did it, they can just click cancel. And it stops. If they come in here and they decide to enter in a password that doesn't allow them access to it, let's say they try to enter their same password, user one and 1234, and then a discount of point nine and click OK, you see it just simply exits and does nothing. If you then come in and try to enter something that doesn't exist, with a discount of point nine, it'll tell you there's an error. And it'll allow you to try again. If we then finally enter a password that has access to that field, you'll see it changes in the background and now the user has to log back on. Notice they don't have a cancel button. They have no choice. So user one, 1234. And we're now logged back on and we don't have all the abilities to do anything. We're back with user one. So let's log back on using our accounts form, through admin, and we'll come back here. Now we can access Script Maker and take a look at that script. It's called discount and it's pretty long. We start off with allow user port. Off. The default is on and like set or capture, it only asks for that script. You have to set it off or on for every script that you want to run again. Typically you're setting it to off because you don't want people to cancel with command period or Apple period on the Macintosh or the escape key. In other words, when the script is running, they can't stop it. You're familiar with set error capture. And we want to capture some errors. Then you also notice that we have these different comments here, done with the comments script step. These help you go back and remember what you did to help make sense of a complex script. So this comment right here describes this script step. So it stores the current portal row because when we do a log in, we lose the current portal row so we need to be able to apply that discount to it after we log in. And here's another comment. Come down here, it goes from here to here. I put the same comment to designate this as all the manager log in stuff. So the first thing we do is we say set the X discount to nothing. Then, inside the loop, we set X account and X password. These are the three fields, these ones right here, that you see in that first dialog when we click the button. But I do this one outside of the loop because I really don't want them to have to keep entering that discount every time in case they make a mistake. But I do want them to re-enter the account and password. If they enter them incorrectly, I want them to be blanked out. So that's why ones outside the loop and these two are inside. Once they're initialized, then we give them this dialog. It says manager approval required. Please enter account, password, discount. We come over here we can see X account, X password and X discount. And you can see with these, when we said use the password characters, so you can do this right in front of your employee, unless they're looking at your hands and can see what you're doing, we'll, they're not going to be able to remember the password. So that's a neat little feature. Ok, and also remember there is an ok and a cancel button here. So if they click cancel, which is message choice two, it simply commits the records so that no fields are selected and halts the script, which says let's just stop everything. And we don't want to just exit the loop because then it'll go down to the end of this loop and continue on with this, which is the portion which allows you to do the staff log in. So we want to actually halt it right there if they click cancel. If they don't click cancel, then we're going to attempt to re-log in, just like you saw in the other one, use X account and X password and if there's no error, in other words, the error is zero, then we know we've successfully logged in with that manager and otherwise we can say oh, well, you know, you get some kind of error, there must be an error and it will come up and go to the end loop and then go back up and start the process over again. Otherwise, if it's zero, in other words, they logged on properly, it goes to end loop and continues on down here. Here's where the portal row gets reselected, using that variable, it's by calculation right here. Just enter dollar sign row, and again, if you're using FileMaker 7, just use a global field, and then reason we need to do that is because we need to make sure we set the context properly for our set field. If we don't, it'll go to the first row of the portal instead of the row we selected. And we simply say take X discount and put it in the discount field. Now, if that causes a problem right there, in other words, if somebody logged on with user one, 1234 instead of admin, well, that would give an error 201 right there when we tried to set that field because remember, we limited access to it. It would then also halt the script; otherwise it would bet by it, go to the staff log in, which is a lot like the manager log in. It allows you to initialize these fields and it asks you for an account and password, same thing, global fields here with the radio buttons, and then it attempts to re-log in using that account and password. If there's no error, then it exits the loop and it's done; otherwise it says there's an error and it requires them to go back up because there's no cancel on here. There's no cancel choice. So they have to re-log in. They'll be stuck in the loop forever unless the do that. And the only way to get out of it is to force quit the solution and that's going to require them to log back on anyhow. So either way you have them captured inside this loop and they have to log in with the password and account that they know. And so that's it. That's all you need to do. It's fairly complicated, but if you understand it and can copy it down, you're doing pretty good right now at this point. You don't have to worry about completely understanding it the first time through. Work with it, try to program it in, go through it, make sure you understand it, leave it alone, come back again and I'm sure you'll eventually feel comfortable with this script.
Tutorial Information
| Course: | FileMaker Pro 9: Intermediate |
| Author: | John Mark Osborne |
| SKU: | 33823 |
| ISBN: | 1-934743-30-5 |
| Release Date: | 2007-11-13 |
| Duration: | 10.5 hrs / 130 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 