4 Replies Latest reply on Dec 21, 2009 2:03 PM by hesswriter

    Auto create related records



      Auto create related records


      I've created a database with a list of parts and a list of line items that contain each separate item ordered.  I've created a relationship between the part # fields of both tables and have checked the box to "Allow creation of records via this relationship."  However, when I order a new item via the line items table, nothing happens. I want this record to creat a new record in the parts list.


      Please help! Thanks!


      Using FM 9.0.3 Avanced

        • 1. Re: Auto create related records

          Please spell out what you are doing step by step--that'll help us spot where things have gone wrong for you.


          Are you "ordering a new item" by entering data in a portal? (That's the usual way to make use of the "allow creation of records..." relationship option.)

          • 2. Re: Auto create related records

            I have a table called "Ordering."  The individual items on the order are in a another table called "line items."  This info is viewed on the "Ordering" layout through a portal, yes. I have a layout tied to the "Line Items" table on which I enter items to be ordered.

            However, what I would like to have happen is this:


            When I enter a new individual item into the "Line Items" table, I would like that action to create a new record in the "Parts" table, so long as the part number doesn't already exist in the "Parts" table.  I have made the "Part Number" field unique. I have a one-to-many relationship between the "Parts" tabel (one) and the "Line Items" table (many.)  At this point, when I enter a new part number into "Line Items" it does not create a new record in the "Parts" table.



            • 3. Re: Auto create related records

              Filemaker is doing what you've set it up to do. Its just not doing what you want it to do.


              With the "Allow creation of records via this relation option" set in a relationship, you use the relationship to create new records in a related child table that will automatically receive the key value of the current record in the Parent table. Creating a new LineItem record from the Odering layout won't create a matching related record in the parts table automatically. You'll have to either script this or design a different layout for adding new parts to your part table.


              What relationship do you have linking LineItems to Parts?


              Usually, you have a serial id number defined in parts and selecting a part number from a value list either looks up matching data (especially price) or simply refers to it (descriptions, inventory on hand etc.) from the parts table. If this is how you've set things up, you'll have to script the creation of a new record in Parts and then use the new serial number for this record to update a field in LineItems.

              • 4. Re: Auto create related records

                I will write a script to create the new record.


                Thank you!