5 Replies Latest reply on Jan 28, 2010 11:20 AM by hspiegl

    Creating Records via Relationships



      Creating Records via Relationships


      Hi, I've been trying to get FMP10 to create new records via relationship without success. My database has Customers and Job Management tables from within Job Management I want to create a new customer. For existing customers the Job Management performs a lookup of all of their details quite happily.


      I've checked the boxes in the Relationships windows every which way I can and haven't succeeded.


      Any help appreciated.

        • 1. Re: Creating Records via Relationships

          Howdy hspiegl,


          It sounds like you've allowed creation, but aren't telling it to create a customer record.

          Making the assumption that when you create a new customer you'll want to enter some data about them...


          Have a "create new customer" button that runs a script:

          New Window

          GotoLayout (CustomerLayout)

          New RecordRequest


          This will open your customer layout in a separate window and let you add customer details.  When you close the customer window, you'll be back at your Job Management layout on the same record you left.


          Is this what you're looking for?

          • 2. Re: Creating Records via Relationships



            I'll give it a spin - it makes sense!


            I'll report back. 

            • 3. Re: Creating Records via Relationships

              Nearly there!


              Yes, thanks I've tried this and it does create a new customer but it doesn't populate this data on the Job Management table where I wanted it. It sort of needs a script that says "use this data in the window where we started"





              • 4. Re: Creating Records via Relationships

                The data from customer is linked to your Job table, via customerID, right?


                So the "use the data I just entered" step would be in putting the correct customerID into the Job::CustomerID field.


                You could script this, but I think it might be a bit dangerous unless you can identify precisely which Job record you want the customerID tagged to.  I can easily imagine that you set up a customer and want to attach the customer to a Job other than the one you left.  And now you've overwritten a field....ooops.


                The safer way would be to use a value list on your Job layout.

                Set up a value list {CustomerID} based on the field Customer::CustomerID showing only values from a second field Customer::Customer Name.  Sorted by the second field


                Put the Job::CustomerID field on your Job layout set up as a dropdown using the valuelist {CustomerID}...using autocomplete.


                Now when you're done entering your new customer and close the customer window, click on the customerID field and choose the customer you just set up.


                Can you automate this like you describe...yes.  Are you sure it's worth the risk?

                • 5. Re: Creating Records via Relationships
                     Thanks Ninja, what you describe is where I have now got to and thanks for the warning about scripting. I think that I need to stop and think about my general flow within this database. As with many it has grown organically over a period of years starting out as a fairly simple database - if I started again I would do it differently! Thanks.