The FileMaker Show Custom Dialog Box

From Dwayne Wright PMP - Certified FileMaker Developer
TWITTER: dwaynewright
YOUTUBE: FileMakerThoughts

There are times in which it is handy to show a message to your FileMaker users. This can be an informative action (hey there!) or conditionally branch the database workflow (do this, do that or do the other). There are at least three ways this can be accomplished. One is to create a new layout that looks like a dialog box and then you take the user there. Another way is to purchase a third party plug-in product that gives a developer an array of robust options. My favorite and the point of this posting is to discuss the third option. This being the Show Custom Dialog box script step. This handy method has many  features such as ...

- the ability to show a customized title and message
- the ability to add data into three possible fields
- the ability to include three buttons that branch a script accordingly.

Other  features  include  the  ability  to  use  literal  text  or  a  calculation  to  show  the  dialog  box  title,  the  dialog  box  main  message  and  the  labels  for  the  input  fields. 

An example file can be downloaded by clicking (here)

You can hard code information or use calculated values in the title and message areas. Using a calculated value, you can craft almost any kind of message for any type of situation you can imagine.

Here  you  can  see  the  General  Tab  of  the  Specify  Custom  Dialog  Box.  Notice  how  you  can  choose  to  enter  in  your  own  Dialog  Title  and  Dialog  Message  information  (  either  a  literal  text  string  or  via  a  field  in  the  database  solution  ).  You  can  also  see  how  you  have  3  tabs  for  allowing  input  fields  into  the  database. 

The fields that you use for data entry do not have to be on the current layout and field validation you have setup for the selected fields will still take place. The same is true for any access privilege settings you might have for those fields, although those settings can be overridden using that check box option in the script itself.

If you use global fields for data entry in the Custom Dialog Box, you might want to clear them of data at the start or end of the script. Otherwise, they may contain the data the user had included in a previous execution of this script in the same session.

Here  you  can  see  the  second  tab of the Show Custom Dialog box is activated and  you  can  click  a  check  box  to  enable  the  feature  of  entering  data. These options pass data to fields in the database as the user types in content. You  can  specify  which  field  that  data  goes  to  and  even  show  the  password  dot  characters  as  the  user  enters  the  data.  You  can  also  specify  the  label  name  for  the  input  field  (  either  literal  string  or  a calculated value).

How about we go back and discuss those buttons we can include in our dialog box? We can add up to three buttons in the dialog box and ultimately these can be used to execute different operations. Under the hood, FileMaker has the ability to tell the script which button the user selected. Here we need to discuss the Get(LastMessageChoice) function.

Using this function, you can see which of the 3 possible choices the user made from the dialog box the Show Custom Dialog script step provides.

In the dialog box, the users selection of the first choice on the right will return a 1

In the dialog box, the users selection of the middle choice will return a 2

In the dialog box, the users selection of the first choice on the left will return a 3

It is kind of weird but the order is reversed when the developer is setting up the Show Custom Dialog. In this case, the option to the far left is the default and returns a 1 by the Get(LastMessageChoice) function, then then goes to the right.

This is what the developer sees.

This is what the user sees when the script is executed.

The way the Get(LastMessageChoice) is used in a script is that after the Show Custom Dialog script step, the developer would include a set of branching IF statements. Depending on the result returned from the Get(LastMessageChoice), aka the choice made by the user via the dialog box, the script will perform a set of script steps.

This is what a typical script may look at using the above examples as context.