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) ]
Go to layout ["Orange layout" (Orange) ]
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.
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".
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)]
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.
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.
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.
Thanks Phil for all your help on this. I now have it working exactly how I want it.