8 Replies Latest reply on May 27, 2015 8:09 PM by NigelBurton

    Selecting layouts by calculation

    NigelBurton

      Title

      Selecting layouts by calculation

      Post

      Hoping someone can help, my script writing skills are quite basic.

      I have a database where the majority of tables are linked by order number. I want to write a script where the user enters an order number in a custom dialog box and then the script looks at a field in a table called "New order" related to this order number called "Product" and depending on what it finds in this field opens up a specific layout and displays the information from another table called "Orders" related to the same order number.

      Any help would be greatly appreciated.

        • 1. Re: Selecting layouts by calculation
          philmodjunk

          There are two basic approaches for a script to select different layouts:

          The go to layout step has a pair of options: "Layout name by calculation" and "Layout Number by calculation" that can be used if you have the exact layout name or number in a field or variable (or that can be created in a calculation).

          Go to Layout [IF ( Table::Field1 = "apple" ; "apple layout" ; "Orange layout" )]

          Or you can set up an If block with different go to layout steps:

          If [Table::field = "A" ]
             Go to layout ["apple layout" (Apple) ]
          Else
             Go to layout ["Orange layout" (Orange) ]
          End If

          • 2. Re: Selecting layouts by calculation
            NigelBurton

            Thanks for the response Phil,

            However it only partly answers my question, before looking at the field in the table I want to find a specific record (and the record will be different every time the script is run) in the table and then look at a certain field and based on what it finds in the field it then chooses a layout to go to and loads the corresponding record that was searched for at the start.

            Not sure if this is even possible.

            • 3. Re: Selecting layouts by calculation
              philmodjunk

              It is quite possible, but it is not clear what part of the above outline is not currently working for you and there are many missing details.

              A script can locate a specific record using a scripted find or Go To Related Records. But how is that "specific record" specified? Will the user select a value from a list or will some other method need be used? The rest of this is handled in my previous example. Table::field would be that "specific field" that the script "looks at".

              • 4. Re: Selecting layouts by calculation
                NigelBurton

                I am trying to use a custom dialog box that asks the user to enter an order number. The steps I have at the moment are as follows:

                Enter Find Mode []

                Show Custom Dialog ["Find Order";New Order Creation::Order_Number]

                Perform Find/Replace []

                If [New Order Creation::Product = "Prime Rolled ERW Line Pipe"]

                Go to Layout ["Orders Pipe" (Orders)]

                End If

                Eventually my plan is to have multiple If statements for the different types of products. My problem is I really do not know how to start to find the order number in the script.

                • 5. Re: Selecting layouts by calculation
                  philmodjunk

                  Perform Find/Replace is the wrong script step. You need: Perform Find []

                  You might also find this thread of scripted find examples helpful: Scripted Find Examples

                  • 6. Re: Selecting layouts by calculation
                    NigelBurton

                    Thanks Phil it now works.

                    My next question, how in the same script do I get the new layout to automatically show the data that relates to the order number that was found in the first step as they are looking at different tables.

                    • 7. Re: Selecting layouts by calculation
                      philmodjunk

                      They would need to be linked in a relationship that make this possible. And in some cases, you might use Go To Related Records to pull up a related record on a layout based on the related record's table.

                      • 8. Re: Selecting layouts by calculation
                        NigelBurton

                        Thanks Phil for all your help on this. I now have it working exactly how I want it.