Classic Example Of Portal Mind Reader

From Dwayne Wright PMP - Certified FileMaker Developer
WEB: www.dwaynewright.com
EMAIL: info@dwaynewright.com
TWITTER: dwaynewright
YOUTUBE: FileMakerThoughts

Recent updates to FileMaker make this technique largly unnecessary but it was quite popular back in the day. You may run into it in solutions that may have been created with earlier versions of FileMaker. In this example, we are showing you how a relationship can attempt to read your mind. In many ways, this technique is no longer needed because FileMaker now has an auto complete option for fields but then again I run into circumstances where I like using a portal for mind reading. In particular, when I have the user selected data from a pop up window / layout.

So this technique is a little long in the tooth but I think you may find it interesting none the less.

In the Entry field, type in the letter A and the portal will refresh to return possible matches. Continue typing the other letters of the alphabet until you get to the letter F, pausing a couple seconds after each letter ( A, AB, ABC, ABCD, ABCDE and ABCDF). You will see the list of possible choices change in the portal. When you see the selection you want, then you click the Pick Me button in the portal.

The child or foreign key in this example is a mulitple line key. It reads the first six characters of the Company name. Each additional character is added to the string with a carriage return between them. The calculation looks like this ...

Left(Company,1) & "¶" &
Left(Company,2) & "¶" &
Left(Company,3) & "¶" &
Left(Company,4) & "¶" &
Left(Company,5) & "¶" &
Left(Company,6) & "¶"

NOTE: If you have records in which the company name may be blank, you will want to use the first six characters of the contact name instead.

Since FileMaker cannot execute a script except via clicking a button or choosing a menu option, we had to do something a little different to get this to work. The entry field is a button that calls upon a script. This script is a loop that has the steps of

Loop
Exit Record
Go To Field [ parentkey_global]
Pause Script [ 1 second ]
End Loop

NOTE: You may want to add a “Create New Contact “ button in case the record does not appear in the list. This script would want to exit you out of the script loop we cover above.

The Pick Me button is a very easy script and has the following steps...

Set Field [ Selected_Company, MReader::Company
Halt Script

This sets the company field to the related value in the picked portal and halts all scripts, including the looping one used in the reader.

This could come in handy in some situations where you are doing data entry. This look ahead feature may help reduce the number of data entry mistakes and reduce the amount of time needed to accurately enter in a record.

An example file can be downloaded by clicking (here)

© 2010 - Dwayne Wright - dwaynewright.com

The material on this document is offered AS IS. There is NO REPRESENTATION OR WARRANTY, expressed or implied, nor does any other contributor to this document. WARRANTIES OF MERCHANT ABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY DISCLAIMED. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.