SeedCodeCalendar8

Deleting Contacts

Overview

The discussion below largely applies to both Contacts and Projects, except for the section on Cascading Deletes, where we discuss contacts only. See Deleting Projects for information about specific cascading deletes in the Project's relationships.

We've put some structures in place to prevent the accidental deletion of important Contacts and Projects: such as Contacts with projects linked to the, or Projects with phases underneath them. At the same time, we want to prevent the creation of "orphans", such as related phone numbers left over when their parent contact is deleted.

We've endeavored to do this in such a way that we can leave the software unlocked, and interfere with basic FileMaker functionality as little as possible. Should one wish to remove the status area or remove all menu commands, there are certainly other methods one could use to accomplish these goals.

In this template we've chose to protect records with a Custom Delete Menu which calls our delete script instead of FileMaker's default delete command. We've also enabled cascading deletes for some relationships in the SeedCodeContacts file. In the sections that follow you'll find more details about each technique.

Protecting Records with a Custom Delete Menu.

The SeedCodeContacts file loads a Custom Menu on startup. This is done in the file's "Upon Opening" script (there are no custom menus in SeedCodeCalendar.fp7). This custom menu, called "Scripted Deletion" differs from the standard FileMaker menus in only 2 respects: the "Delete Record" and "Delete All Records" steps are mapped to our own scripts so that we can prevent deletion of Contacts and Projects in some cases. For example, we test to see if a Contact is associated with any Projects before the contact is deleted.

You can change the behavior of these pre-deletion tests by editing the scripts "Delete Contact { Dialog }" and/or "Delete Project { Dialog }". Each test within these scripts is commented out so that you can easily amend or omit these tests. When it comes to omitting the test, see the section "Delete Records Anyway" below.

Note that this custom menu completely maps the native FileMaker delete to our scripts: that includes the delete keyboard shortcuts and the toolbar's delete icon. All of these now call our delete scripts. If you add delete buttons to the Contacts or Projects interface, you may wish these to call our delete scripts as well.

Editing the Custom Menu

You'll need FileMaker Pro 8 Advanced (FM8A) to edit the custom menu directly. However, since the menu really just calls a couple of our scripts, you can edit those scripts to effectively alter the delete behavior this menu imposes: you don't need FM8A to do this. The scripts called are "Delete" in the case of the "Delete Records" menu item, and "Delete All" in the case of the "Delete Found/All Records" menu item.

Turning off the Custom Menu

If you wish to simply revert to FileMaker's default menu set, you can do this by editing the Upon Opening script so that the "Install Menu Set" script installs the "Standard FileMaker Menus" instead of our menu set. Then run this script by hand or by reopening the file to reset the menu (you do _not_ need FM8A) for this. Note that turning this off can be very useful when it comes to deleting our sample data from the template. Just be sure to remember to switch the "Install Menu Set" script back when you're done.

Delete Records Anyway

You may find our deletion tests too cumbersome. For instance, you might not care that a contact is associated with a project and might wish to delete the contact anyway. If so, you may wish to use Cascading Deletes to make sure your deletions don't create "orphans".

Orphan Control with Cascading Deletes

"Orphaned" records are those whose parent record has been deleted: related phone numbers left over when a contact is deleted, for instance. We prevent orphaned records in SeedCodeContacts by turning on the relationship option to "Delete Related Records in This Table when a Record is Deleted in the Other Table". This means that when you delete a contact from SeedCodeContacts, all phone, fax, and email records for that contact are deleted automatically. This is _almost always_ a good thing, but there may be times when you want to turn this process off for a while: such as when you're importing and deleting lots of duplicate data.

So, for your reference, here are the relationships which have such Cascading Deletes turned on:

From Contacts To...
ContactEmailFaxPhone
ContactAddr
(We suggest you leave activity in place when we deleting contacts but if you don't want to, you can turn Cascading Deletes on from Contacts to ContactActivitySimple.)
From Projects To...
ProjectApptOverview
(We again suggest you leave activity in place when we deleting projects but if you don't want to, you can turn Cascading Deletes on from Projects to ProjectActivitySimple.)
(You could also turn cascades on from Projects to Project_PhasesSimple to delete a project's phases when you delete the project but we don'rt recommend it.)
(855) SEEDCODE
[email protected]
Follow us: