1 2 Previous Next 22 Replies Latest reply on Oct 20, 2015 12:16 PM by andresen

    Add new record in a floating button

    andresen

      Hi!

      Try to fix this floating button that I use in one layout but want to add new record from another table.

       

      Ex. In order layout I want to make a new customer. I have tried to make this but ending up with a new order record instead.

       

      Don't know what to do anymore. Suggestions?

        • 1. Re: Add new record in a floating button
          Mike_Mitchell

          A popover always uses the same context (underlying table occurrence) as the layout it's on. In order to create a new record in another table, you need to use a relationship. It's possible, but you have to do a bit of extra work.

           

          Here's one method.

           

          1) Create a global field in the current table. It should be of the same type (number, text, etc.) as the key field in the target table (where you want to create the new record). The key field in the target table should be of an auto-create type (serial number or other auto-enter option).

           

          2) Create a relationship between the current table and the table you want to create the new record in, based on the global field (current table) and the key field (target table).

           

          3) Put the related fields into the popover.

           

          4) Create a script that sets the global field to a null value (empty) in the current record.

           

          5) Set that script to execute OnObjectEnter when the popover opens. This will clear the relationship between the two tables.

           

          6) Set the same script to execute OnObjectExit when the popover closes. This will save the new record in the target table.

           

          What I'm describing is often referred to as the "magic key". (You can search the web for a more complete description.) Basically, it exploits a FileMaker behavior that sets the value on the parent side, when missing in a global field, equal to the auto-enter value on the child side when a new record is created. This allows you to create new child records from any context.

           

          HTH

           

          Mike

          • 2. Re: Add new record in a floating button
            andresen

            Thanks!

            Need some help on no 4-6. Do you have a example? I tok a look on the finish invoice that came with Filemaker. To advanst for me. Is it possible to simplify?

            • 3. Re: Add new record in a floating button
              Mike_Mitchell

              See if the attached file works for you.

              • 4. Re: Add new record in a floating button
                andresen

                Sorry, I don't see any attached file?

                • 5. Re: Add new record in a floating button
                  Mike_Mitchell

                  You have to look on the forum. Doesn't come across in email.

                  • 6. Re: Add new record in a floating button
                    Mike_Mitchell

                    Go to your profile, click on Activity. The thread should show up there. (The forum couldn't see it via the email link for some reason.)

                    • 7. Re: Add new record in a floating button
                      andresen

                      Yours working find, I tweaking around to make it work in my solution. Your working for one company with several client.

                       

                      I try to make it happened for in one order create a new customer if necessary.

                       

                      Primary key and secondary key, is that aplaceble in this case?

                      One to many relations. In our case, you have several client for one company. I get that. But still if I have one customer they can have several orders. And in one order there can be only one customer.

                      • 8. Re: Add new record in a floating button
                        Mike_Mitchell

                        You can add fields to the setup as needed and set them in the exit script. For example:

                         

                        Set Field [ customer::OrderNo ; newValue ]

                        Set Field [ customer::OrderDate ; newValue ]

                        Set Field [ company::clientIDGlobal ; "" ]

                        Commit Record / Request

                         

                        You can save the new values in global fields prior to opening the popover. Or, you can give the user the ability to set the field. You may need to add another table occurrence to the database and set up the join there as well, depending on your particular relationship model (for example, if there's a join table).

                        • 9. Re: Add new record in a floating button
                          andresen

                          I don't follow you in your last reply. NewValue, is that too make it go up one number for every entry? How do I get the new number?

                           

                          You see my ERP diagram under and I'm in layout, orders, where I pic the customer and if the customer don't exist I want to use a popup button to create a new one. Automatically it will give the new customer a unik number and I only want to fill in the regular info about the customer.

                           

                          Now, customer is a parent and the orders is child. When I try your solution I get the opposite whit the customer and orders??

                          When I see your solution it's more like my contact and customer. Is it possible too make it my way, customer and orders?

                          custumer and orders.jpeg

                          • 10. Re: Add new record in a floating button
                            Mike_Mitchell

                            I don't understand what you're asking.

                             

                            1) What is your parent layout?

                             

                            2) What child record are you wanting to create?

                            • 11. Re: Add new record in a floating button
                              andresen

                              1) Customer is parent to both contact and orders. But Orders is parent to orders/products.

                               

                              When I work with an order I'm in layout Orders. Therefrom I sometime want to make a new customer in a floating button. That is the big question.

                               

                              2) I'm not sure! It should be the customer but that is a parent... Can it be both?

                              • 12. Re: Add new record in a floating button
                                Mike_Mitchell

                                I'm asking the question from the perspective of this particular operation. So for the purpose of this operation, your parent is Orders, and your child is Customer. You want to create a new Customer from Orders, yes?

                                • 13. Re: Add new record in a floating button
                                  andresen

                                  That's correct. It's confusing me around...

                                  • 14. Re: Add new record in a floating button
                                    Mike_Mitchell

                                    Then the original demo will work fine. Just replace the parent table with Orders and the child order with Customer. You don't need any additional fields.

                                    1 2 Previous Next