1 Reply Latest reply on Mar 19, 2013 8:53 AM by philmodjunk

    Referential integrity in parent / child relationship

    cowtrax

      Title

      Referential integrity in parent / child relationship

      Post

           I have a parent / child relationship and I want to warn the user if they try to delete a parent record while there are child records existing.  I understand that I can automatically delete the child records by checking the appropriate box in the relationship diagram but what I want to do is to give a warning that this is going to be done or to force the user to individually delete the child record so they are absolutely aware of what they are doing. 

           Is this possible through the "normal" validation or do specific scripts need to be written to check for these relationships at the time of attempted deletion of the parent.

           Help would be appreciated.   Thanks.

            

        • 1. Re: Referential integrity in parent / child relationship
          philmodjunk

               It would be nice if "delete record" were an event for which Filemaker had a script trigger. Then we could simply define a script trigger to perform a script before the record is deleted with Exit Script [False] used as a way to cancel the delete record action.

               But since you don't have that option, you'll need to set up a script for deleting the parent record and use one interface design option or another to make the standard delete record action unavailable to the user.

               The delete record step can use this If step:

               If [ Not IsEmpty ( ChildTableOccurrence::ParentID ) ]

               as a test to detect the presence of child records.

               Ways to make the standard Delete Record unavailable:

               With Filemaker Advanced, you can use a custom menu set that removes Delete Record from the records menu for this layout. Or you can put your delete records script in place as the action that takes place when delete records is selected or when it's keyboard short cut is pressed.

               WIthout FileMakder Advanced, you can use Record Level Access control settings in the user's privilege set to either prohibit deleting records or to only permit deleting records when there are no child records for the record that is being deleted.

               See "Editing record access privileges" in FileMaker Help and check out this particular sub section: "Entering a formula for limiting access on a record-by-record basis" for a description of how to set this up.