10 Replies Latest reply on May 24, 2012 1:16 PM by philmodjunk

    Simple parent - child relationship problem...I think?

      Title

      Simple parent - child relationship problem...I think?

      Post

      Hi, I'm new to Filemaker and have a problem I hope someone can assist me with.

      I have two tables and two layouts:

      Customer and Notes

      On my customer layout, I have a note field that I want to display all the notes for that customer. I also have a "add note" button on the customer layout which takes you to the notes layout. 

      Question 1:  How do I "connect" the notes layout to the customer layout?  I can get the notes table to record the customerID.  So when you click on the "add note" button, the notes layout should open, which it does, but the customerID is not recorded in the Notes table.

      Question 2:  How do I display all the notes added in the "notes" field on the customer layout?

      Thanks in advance for your assistance.

      Matt

       

        • 1. Re: Simple parent - child relationship problem...I think?
          philmodjunk

          Q1, do you need a separate layout?

          If you place a portal to Notes on your customer layout, you can add, delete and edit all the notes for that customer directly on your customer layout.

          This script will take the current customerID and enter it into a new note record on your notes layout:

          Set Variable [$CustID ; value: Customer::CustomerID]
          Go to Layout [Notes (Notes)]
          New Record/Request
          Set Field [Notes::CustomerID ; $CustID]

          Such a script can be useful even if you decide to use the portal as you can include freeze window at the start and Go to Layout [original Layout] at the end and the script will add a new note that automatically appears in your portal. If you sort your notes in the portal so that the most recent note is at the top of the list, this script becomes useful as adding a new note directly in the portal requires scrolling to the end of the portal records, entering the data and when you exit it pops back to the top.

          Q2: Use the portal. This is something you can research in FileMaker Help to learn more.

          • 2. Re: Simple parent - child relationship problem...I think?

            Thanks PhilModJunk.

            Question, where do I place the script?  I have the script assigned to the "add note" button on the customer layout and it still does not work correctly.

            The reason for the note portal not on the customer screen is I want the customer layout read-only but I want users to be able to add notes for each customer.

            Thanks,

            Matt

            • 3. Re: Simple parent - child relationship problem...I think?
              philmodjunk

              The rest of the layout can be read only yet permit adding notes in the portal.

              The script should work for you. "it still does not work correctly" does not tell me how it failed for you.

              Exactly what happened when you tried the script?

              The script assumes that there is already a value in the Customer::CustomerID field.

              Also, if you see more than one pair of [] in your set field step, it's not correctly set up and you won't see a value appear in the notes::customerID field.

              • 4. Re: Simple parent - child relationship problem...I think?

                Sorry PhilModJunk. 

                The "add note" button did the same thing as before adding the script to it.  The button will take me to the notes layout as a new record but does not add the parent contactID to the notes table. 

                Yes, on the customer layout page, I have the customerID displayed.  I also have a field on the notes layout page for the parentID to display so I can see if it is working.

                Attached is a pic of my tables.

                Thanks again.

                • 5. Re: Simple parent - child relationship problem...I think?
                  philmodjunk

                  Yes, but what does your script look like?

                  I suspect you have a detail in that script not quite right.

                  The set field step should look exactly like this:

                  Set field [Notes::_fkContactID ; $CustID]

                  The set variable step should look exactly like this:

                  Set Variable [$CustID ; value: Contacts::Contact ID Matching Field]

                  _fkContactID should be a field of type number and Contact ID Matching Field should be defined as either an auto-entered serial number or with an auto-enter calculation that enters Get ( UUID ).

                  You may need to upload a screen shot of your script in the script editor.

                  • 6. Re: Simple parent - child relationship problem...I think?

                    Script:

                    Set variable [$ContactID; Value:Contacts::Contact ID Matching Field]

                    Go to Layout ["Notes" (Notes)]

                    New Record/Request

                    Set Field [Notes::_fkContactID]

                    The difference is the last line.  In the Set Field, I can not add the ; $CustID.  FM v12 for Windows will not allow it.  When I click on the "specify target field" button, this the screen that appears.

                     

                    • 7. Re: Simple parent - child relationship problem...I think?
                      philmodjunk

                      This is a common "newbie" mistake with set field.

                      When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.

                      • 8. Re: Simple parent - child relationship problem...I think?
                        GuyStevens

                        The specify target step is correct. That field is the field you are going to set your variable to.

                        You also have to specify which value you will be setting. And that can be done by clicking the "Specify" button after "Calculated Result"

                        That's where you set the value.

                        And in ths case that value is:

                        $ContactID

                        • 9. Re: Simple parent - child relationship problem...I think?

                          Thanks again PhilModJunk!!

                          That was it.  Script works now.  Yahoo!

                          One minor question though, when the script takes me to the notes layout page, the most recent note in the table is displayed.  Should a "new" record be created?

                          • 10. Re: Simple parent - child relationship problem...I think?
                            philmodjunk

                            Yep.. That's what New Record/Request does in this script.

                            You should see Notes record that is blank, except for the value in the ID field.