8 Replies Latest reply on Oct 26, 2016 9:46 AM by philmodjunk

    How to keep context when switching layouts?

    pbedouk

      Title

      How to keep context when switching layouts?

      Post

           Hi

           I have a customer table and layout and a NewOrder table and layout.

           I want to add an order for a customer via a button/script from the customer layout to the order layout.  This would be to create a related record (a new order linked to a cusrtomer).

           It seems that when I switch layouts (via 'go to layout'), I loose track of what customer record I was viewing on the customer layout.

           I see this via the data viewer and watching the values for match fields and name fields.  All the fields go blank as soon as the go to layout script step is executed.  I think I have lost contact with the customer record.

           what do I do to connect back to the customer when creating a related record?

           I don't really want to do this via a portal.  there is too much new information to add about a new order to fit comfortably on my customer layout.

           Thanks,

           Peter.

            

            

        • 1. Re: How to keep context when switching layouts?
          RickWhitelaw

               You can create a related record without using a portal. A simple example  would be if you had a table of contacts with address being in a seperate table. If you had a field from the address table on your Contacts layout and you had a match field between the tables as well as "allow creation etc." checked in the relationship graph, then when you entered an address on your contacts layout it would be recorded in the related table. This seems to be something often ignored in these discussions, but it's one of the basic db principles. Sorry if  you already know this.

          • 2. Re: How to keep context when switching layouts?
            pbedouk

                 Thanks Rick,

                 I didn't know that.  Might be useful later.

                 But I was hoping to create the related record from a different layout altogether.  Using your example I want to navigate away from the contact layout/table to an address layout/table where I would enter the address and create the related record.  I guess I'd need to populate the key field myself, but how?

                 Peter

            • 3. Re: How to keep context when switching layouts?
              philmodjunk

                   Set Variable [ $CustID ; Value: Customers::__PkCustomerID]
                   Go to Layout [Orders]
                   New Record/Request
                   Set Field [Orders::_fkCustomerID ; $CustID]

              • 4. Re: How to keep context when switching layouts?
                pbedouk

                     Thanks!  Works perfectly.

                • 5. Re: How to keep context when switching layouts?
                  basilisk2

                  Would I be right in thinking that if I want to simply move to another table without creating a new record then I just leave out line 3 in your script Phil, the New Record/Request script step?

                  • 6. Re: How to keep context when switching layouts?
                    philmodjunk

                    Depends on what you want to do. You would need to either also leave out the set field step or use one method or another to find the correct record to update if you want to modify data in a record of the other table.

                    • 7. Re: How to keep context when switching layouts?
                      basilisk2

                      So, there is not straightforward way to carry the record ID from one layout to the next? On a single layout one can use a Portal but what if you need more space than a portal allows? Then you need to switch to a second layout connected to the same record. I know there are lots of 'clever' ways to do this, but surely there is a "simplest" solution that is considered best practice for simple databases?

                       

                      Eg Go to New Layout Maintaining Context ( [Layout 2] ; [RecordID from Layout 1])

                       

                      where the first argument is the name of the Layout to go to, and the second argument is the identifier used to maintain context.

                      • 8. Re: How to keep context when switching layouts?
                        philmodjunk

                        To quote from my last post:

                         

                        or use one method or another to find the correct record to update

                         

                        There are multiple methods possible. One method is to put a button in that portal row that uses Go TO Related Records to make that portal record the current record on a layout based on the portal's table.

                         

                        Another method is to copy the ID into a variable, enter find mode, change layouts (or open a window and change layouts) to a layout for that table and then use the variable's value to perform a find for that record.