3 Replies Latest reply on Oct 23, 2013 8:35 AM by philmodjunk

    Relating TOs, a simple question on good practise.

    JohnDee

      Title

      Relating TOs, a simple question on good practise.

      Post

           Ι am relating an invoice table via Client_Id and Shop_Id (in a scenario where many shops issue invoices) and I have to do this via a TO of the invoice table, which takes up the second relation to shop_id. 

      My question is this, in my invoices layout, based on the Invoice Table (and not its second TO) I chose to substitute the Shop_Id field with a ::Shop_Id field from the TO of invoices, since this is related to the shops table. 

      Is what I did superfluous? It's the same field anyway. Should I keep the one on the first Invoice table?

        • 1. Re: Relating TOs, a simple question on good practise.
          philmodjunk

               Why do you need the ID on the layout at all? Many developers make it a practice to keep primary key values hidden from the user.

               The only way that this makes a difference is when you permit editing the field. If editing is permitted, editing ::ShopID edits the value a related record. Editing ShopID edits the value in the layout's current record. Also, the ::field will be blank if there are no related records. So for that reason, you may want to stick with the field from the layout's table occurrence.

          • 2. Re: Relating TOs, a simple question on good practise.
            JohnDee

            Many thanks Phil, your help is much appreciated. 

                 Turns out that if I use the :: field from the second TO (not the one in the layout) the dropdown list won't work for some reason (what?). 

                 I don't need the ID on the layout, but I was looking to populate it via a value list. Turns out value lists with two fields sorted on the second and showing only that won't allow for autocomplete. Which is very important if you are looking over a list that could have a few hundred records.This is a rather disappointing implementation, but what to do. I am now looking at doing it via a script, or using someone's code to get the desired behaviour. 

            • 3. Re: Relating TOs, a simple question on good practise.
              philmodjunk
                   

                        I don't need the ID on the layout, but I was looking to populate it via a value list.

                   Sorry but that's a contradiction. If you are using a value list to modify it, it has to be on the layout.

                   To get auto-complete to work, try the method in this demo file:

                   FileMaker 12 users: https://dl.dropbox.com/u/78737945/SimpleNameLookupDemo.fmp12
                   Pre FileMaker 12 Users: https://dl.dropbox.com/u/78737945/SimpleNameLookupDemo.fp7