If you have a field which holds your layout names (it should be a global field), then you can use that value to switch layouts using that value by using Go To Layout [ by calculation ]. This calculation can refer directly to the global field itself if the value in the global matches a field name, or the calculation can become more complex, similar to:
TVGI::Status = "Pending" ; "Pending" ;
TVGI::Status = "Completed" ; Final Screen"
You can use script trigger OnObjectModify to trigger the script when User makes selection. BTW, Clear normally is not used; Set Field is the preferred step. So if your script is simply to choose a layout name in a pop-up global and then go to that layout, it would be simple:
Go To Layout [ global field ]
If you are using version prior to script triggers then we need to know whether you are Mac or Windows and what FM version you are using. Scripted pop-ups behave differently depending upon OS.
Just to help you understand what your current script does and how/why it fails:
Allow User Abort [on] --this step allows users to press Esc (windows) or command-period (mac) to halt your script before it completes running. Since this is the default setting, it does nothing here. (Allow user abort [off] prevents users from halting a script and this option would remove the cancel button that appears when the script is paused if you had selected off instead of on.)
Clear [Select ; TVGI::DocumentList ] -- if this field is present on the current layout, all contents of this field are deleted. If it is not on the current layout, nothing happens.
Set variable [$Layout ; value: TVGI:::DocumentList ] --this copies the contents of the field into a variable, but since the previous step has most likely cleared this field, there is nothing to copy and the variable will be empty.
Go to Field [TVGI:::DocumentList ]--this puts the cursor in the documentList field--which is currently an empty field...
Go to layout [$Layout] -- if you have specified "layout name by calculation" option, this will take you to the layout whose name is stored in $layout, but if $Layout is empty due to the clear step, it does nothing.
Pause/resume [indefinitely]---pauses your script until you click continue or cancel in the status area
Go to layout ["Quick File Cabinet" (TVGI)] --takes you to the layout named "Quick File Cabinet".
Thanks for the advice. I am a newbie and have been learning from reading your posts and FM books. I was able to simplify the script but I was not able to fine OnObjectModify script trigger. I have FM pro 11 and I am using windows 7. Any advice?
ENter layout mode. Select the field by right clicking it. Select 'Script triggers' from the menu that pops up.
Thank you phil. That's how you can tell how novice I am.