7 Replies Latest reply on May 25, 2017 10:50 PM by philmodjunk

    Switching to new layout to enter a new record

    rjalex

      Dear friends,

      a new baby step in my application needed :-)

       

      I have a Product layout with a pop-up menu field listing all known brands.

       

      If I'm entering a new previously unknown brand I just placed a button to the right of the pop-up field with a NEW label and a script:

       

      New Window [ Style : Document ]

      Go to Layout [ "brand" (brand) ]

       

      not beautiful but it works.

       

      Question 1) When the above button is clicked I am brought to the new layout window but have to manually click the ADD RECORD button. Can I automatically start with a new record (and therefore the auto-sequenced pk) and have the cursor already in the BrandName field ?

       

      Question 2) Is there an easy but more beautiful way to accomplish this task ?

       

      Thank you

        • 1. Re: Switching to new layout to enter a new record
          BruceRobertson

          Regarding item 1; you have a script.

          You want it to create a new record.

          Seems clear therefore that the last step should be New record.

          Yes; there may be nice ways to do this.

          1 of 1 people found this helpful
          • 2. Re: Switching to new layout to enter a new record
            erolst

            Question 1:

             

            Add the steps

             

            New Record/Request

            Go to Field [ Brand::name ]

             

            Question 2:

             

            Create a global field in the BrandName table. Enter the name of a new brand and launch this script:

             

            If [ IsEmpty ( Brand::gNewName ) ]

              Exit Script

            End if

            New Window

            Go to Layout [ Brand ( Brand ) ]

            New Record/Request

            Set Field [ Brand::name ; Brand::gNewName ]

            Set Field [ Brand::gNewName ; "" ]

            Close Window

             

            If you have v16, you can specify the layout directly within the New Window step.

             

            An even shorter method uses a 'Magic Key', but that works best with UUIDs, which at a guess you don't have ...

            1 of 1 people found this helpful
            • 3. Re: Switching to new layout to enter a new record
              philmodjunk

              An even shorter method uses a 'Magic Key', but that works best with UUIDs, which at a guess you don't have ...

              MagicKey works just fine with auto-entered serial numbers.

              2 of 2 people found this helpful
              • 4. Re: Switching to new layout to enter a new record
                rjalex

                Thank you all very much.

                 

                I have v15. Will look into your more sophisticated global field and MagicKey concept which right now I struggle to understand.

                 

                For now I've managed to follow and implement the modified script which lands me in add mode to the brands layout. Already a good progress.

                 

                I now have to understand what's the proper way to go back to the previous Product layout and resume entering the other fields of that record there.

                 

                Right now I manually re-select the Product layout which is not that nice.

                • 5. Re: Switching to new layout to enter a new record
                  BruceRobertson

                  Close Window.

                  You said you started all this by creating a new window. Therefore, when done, close that window and you are exactly where you started, in the original window.

                  1 of 1 people found this helpful
                  • 6. Re: Switching to new layout to enter a new record
                    rjalex

                    Hello. I am trying to understand your second better way but I'm ashamed I don't.

                     

                    So currently I am on a product layout (product table context), click on a brand pop-up field and see I need to add a new  missing brand.

                     

                    I therefore have a "New" button near it which does my "method 1" add.

                     

                    Of your instructions I did understand the global field part. Went to the brand table and added a new gBrandName text field and in its options I flagged the Global checkbox. Right ?

                     

                    Where I get lost is the "Enter the name of a new brand and launch this script" part.

                     

                    Where do I enter the new brand? I am on the pop-up field currently and cannot enter anything there.

                     

                    Thank you for your patience.

                    • 7. Re: Switching to new layout to enter a new record
                      rjalex

                      Doh! Thank you! :-)

                       

                      But I must be doing something strange because after adding a close window at the end of  first script when I click the button I now see the brand layout opening but also an error message saying the brand name must be less than 30 chars before I can enter anything.

                       

                      Where's the error ?

                       

                      Screen Shot 2017-05-26 at 06.14.51.png

                      Thank you !

                      • 8. Re: Switching to new layout to enter a new record
                        philmodjunk

                        You type the brand name into the global field, then run your script. Instead of go to field, put:

                         

                        set field [ Brand::name ; your global field here]

                        1 of 1 people found this helpful