4 Replies Latest reply on Nov 28, 2011 11:49 AM by DavidJondreau

    Establishing a Primary Record



      Establishing a Primary Record


      I have two tables: (1) a "contact" table and (2) a "phone number" table.

      The "phone number" table has a "phone number" field and a "primary" field.

      The contact table has a form with a portal displaying the "phone number table"

      My question is: how do I allow for only one record to be the primary phone number for each contact? I am currently using two radio buttons in the "primary" field--"primary" and "other". If I select "primary", I would like Filemaker to change all the others to "Other".

      Any suggestions would be most appreciated!

        • 1. Re: Establishing a Primary Record

          You'll need to script this. I don't see why you need to radio buttons, one indicating "Primary" is enough. A simple number field that contains a 1 if Primary and is empty if not will do. To make it work, create a button, and name it "Primary", and attach a script to it. When it is clicked, your script will loop through the portal and set all the other phone number records Primary field to empty. The button text should have conditional formatting, and if that portal record is Primary highlight the text in some way.

          • 2. Re: Establishing a Primary Record

            Why not have different tables for types of phone? I have a table for home phone, another for mobile, another for fax etc. you can call them whatever you want. Each child table then has a one to one relationship with the parent.



            • 3. Re: Establishing a Primary Record

              Define a serial number field, PhoneID, in the table of Phone numbers so that each record has a unique value in this field.

              Then define a field, PrimaryPhoneID, in your contacts table.

              When clicking a button in your portal row that selects that phone number as the primary, use this one line script:

              Set Field [contacts::PrimaryPhoneID ; PhoneNumbers::PhoneID ]

              You can use conditional formatting on layout text inside the portal row such that the text is visible if Phone::numbers::PhoneID = ontacts::PrimaryPhoneID and invisible if it is not. Format this layout text as a button and you can get what looks like a checkbox field or a "tick" that you click to select. There'll be no need to loop through the portal records with this script as the only value you need change is the field in the parent record that stores the ID of the selected phone number record.

              Hint: Layout text set to a font size of 500 by a conditional format will be invisible to the user.

              • 4. Re: Establishing a Primary Record

                I agree with Phil's solution over mine.