In this FileMaker how-to, we're going to examine the Get ( LastMessageChoice ) function.
The Get ( LastMessageChoice ) function works hand-in-hand with the Show Custom Dialog script step, therefore, we will also need to take a look at the Show Custom Dialog script step and how it works in order to fully understand the Get ( LastMessageChoice ) function. With that being said, in today's FileMaker how-to, we are going to cover two closely connected features of FileMaker.
The purpose of the Get ( LastMessageChoice ) function is to determine which button the user clicked in the custom dialog.
So you have a better idea of what I am talking about, here's an image of a custom dialog as the user would see it.
So, as you can see in the image above, custom dialogs present users with a message and one or more buttons to click. Custom dialogs are generated by the Show Custom Dialog script step. Let's look at how to setup a custom dialog.
Here's an image of the Show Custom Dialog options. This is where you set all the options for a custom dialog.
So as you can see above, the Show Custom Dialog has a lot of options. We aren't going to cover all of them today. Instead, we're going to stick to the basics.
The basic options that you can set for a custom dialog are:
- You can choose a title.
- You can enter a message.
- You can decide how many buttons to display (Up to 3).
- You can give each button a label.
OK, so now you know the basics of the Show Custom Dialog script step. Now, let's look at how these two features work hand-in-hand.
As I mentioned earlier, the Get ( LastMessageChoice ) determines which button the user clicked in a custom dialog.
Before we go any further, I should mention Get ( LastMessageChoice ) only has 3 possible results: the numbers 1, 2 and 3.
If a user clicks the highlighted button, also known as the default button, Get ( LastMessageChoice ) will return 1 as the result.
If a user clicks the second button, Get ( LastMessageChoice ) will return 2 as the result.
If a user clicks the third button, Get ( LastMessageChoice ) will return 3 as the result.
It's that simple. The Get ( LastMessageChoice ) doesn't do any more than that.
Here's a snapshot of a script that I created in an example file to showcase the Get ( LastMessageChoice ) functionality.
So to get both of these features working together, you'll need to create a script that includes both the Show Custom Dialog script step and the Get ( LastMessageChoice ) function.
The script displays a custom dialog, captures the user's choice and sets it into a field.
Now, because the Get ( LastMessageChoice ) is a function, you will need to access its result either via a calculation or simply by setting a field equal to Get ( LastMessageChoice ). In this case, I outputted its result into a field.
What are some ways to use the Get ( LastMessageChoice ) function? The first thought that comes to mind is prior to running a particular routine, you may want the user to ask the user to confirm that she or he wants to run that process. For instance, prior to deleting a record, you may want to ask the user to confirm her or his decision to delete the record.
Another use case that comes to mind is when giving the user a choice between two or more options. For instance, if your script created an invoice, one option that you may give the user could be to print the invoice, while another may be to send a PDF of the invoice to the customer via email.
The easiest way to become familiar with the Get ( LastMessageChoice ) function is to use it in a script. So, what are you waiting for, go create a script and try it out for yourself!
I've created an example file to help you understand the Get ( LastMessageChoice ) function, which in the future will only be available to Grasp students. For a limited time only, however, we are offering these files free to our newsletter subscribers. So sign up today using the form to the left.
Please let me know if you found this FileMaker how-to useful. Feel free to send me an email with any thoughts or suggestions that you may have.
So, go experiment with the Get ( LastMessageChoice ) and report back in the comments below!