New in 14: Allowed orientations 1 - write script

Document created by mark_baum on Aug 10, 2015Last modified by mark_baum on Dec 4, 2015
Version 4Show Document
  • View in full screen mode





IMPORTANT UPDATE: iOS 9 does not support control over screen orientation. As a result, the new Set Allowed Orientations script step only works on iOS 8 and has been deprecated for future versions of FileMaker Go.

The FileMaker 14 Platform gives you control over which screen orientations are allowed in FileMaker Go. Previously you had to design for both orientations, following either of these approaches:

  • Creating a single layout limited to the area common to both orientations (based on the shorter dimension in each direction), then configuring some layout objects to resize, filling the extra area in each direction as appropriate.


  • Creating two layouts, one for portrait and the other for landscape, and triggering a change from one layout to the other when the device is rotated, using the OnLayoutSizeChange script trigger and the Get (WindowOrientation) function.


These are good strategies when you need to make both orientations available, but they do have drawbacks: in the first case, you don't get the most efficient use of the available screen space, and in the second, you must maintain two different layouts. Now you have a third option: to limit the device to landscape or portrait only, and to design a layout specifically for that orientation. This involves two steps:

  • First you write a script that includes the new Set Allowed Orientations script step, which specifies any combination of four possible orientations (portrait, portrait upside-down, landscape left, and landscape right), typically permitting both portrait or both landscape orientations. That's what the exercise on this page will cover.

  • Then you trigger this script in various ways, such as when the user enters a layout, loads a record, or opens a window. The next page will cover this part of the process.






Write a script that allows different combinations of iOS device orientations in FileMaker Go, while receiving more practice with the new keyboard functionality.

The next page will implement this script by associating it with two layout script triggers. If you need to save time, you can skip ahead to that page, using a version of the script that's already finished ("Trigger | Set Allowed Orientations [orientation] FINISHED").




  • View the finished script

    You can view scripts in more than one window in order to compare them. However, the additional windows do not include the left pane of the Script Workspace.

  1. Choose the Scripts menu > Script Workspace…  ⇧⌘S or Ctrl S

  2. Since you will be using the keyboard, hide the right pane of the workspace.
  3. In the progressive search box of the left pane of the Script Workspace, type: ori

    “Trigger | Set Allowed Orientations [orientation] FINISHED” is the only script whose name includes this phrase.

  4. Control-click (OS X) or right-click (Windows) on the script name. A dropdown appears, including options for duplicating and renaming the script. Note that you can also move an already open script to a new window by control-clicking its tab in the middle pane of the Script Workspace.


  5. Select the “Open in new window” option. The script opens in a new window consisting of the middle and right panes of the script workspace.

  6. Hide the right pane on this new window so that only the script is visible. This script will serve as a model for the script you are editing.

    Create the script

  7. Return to the main Script Workspace window.

  8. Press Command-N (OS X) or Control+N (Windows) to create a script named “New Script”, which appears in the middle pane.

  9. Rename your new script to the following:  Trigger | Set Allowed Orientations [orientation]   then press Enter.

    Add a comment

  10. Type this character to add a comment line: #

    A flashing cursor appears indicating that FileMaker Pro is waiting for you to enter the comment. Note that if you don't type anything, the comment character will disappear (though the blank line will remain), because blank lines and comments are now different things.

  11. Type a comment like the followingThe script parameter determines whether the following combinations of orientations are permitted:  all (default), portrait (both), and landscape (both) then press Enter.

  12. Press Command-Enter (OS X) or Control+Enter (Windows) twice to create two new lines.

    Place your script parameter in a variable

    Placing the script parameter value in a clearly named variable makes its purpose easier to understand throughout your script.

  13. Type the following script step acronym: sv  then press Enter.

    The script step “Set Variable” is added to your script. (Note: three possibilities are presented, but "Set Variable" is the one selected by default.)

  14. Press the spacebar to enter the script step options. A “Set Variable” Options dialog window appears, with the cursor positioned in the Name: box.

  15. Type the following Name: $orientation

  16. Press Tab to move the cursor to the Value box.

  17. Type the following Value: Get(ScriptParameter)  then press Enter.

    Your changes are saved and the dialog window closes.

  1. Press Command-Enter (OS X) or Control+Enter (Windows) twice to create two new lines.

    Add an If / Else statement to decide when to lock orientation

  2. Type the following abbreviation: if  then press Enter.

    The If and End If script steps are added to your script. A flashing cursor indicates that FileMaker Pro is waiting for you to enter the If condition.

  1. Type the following condition: $orientation = "portrait"  then press Enter.

  2. Press Command-Enter (OS X) or Control+Enter (Windows) to create a new line.

    Add the first Set Allowed Orientations step

  3. Type the following acronym: sao  then press Enter.

    The Set Allowed Orientations script step is added with its options set to allow all four orientations. Let’s change it so that the two landscape orientations are not allowed.

  4. Press Tab twice to move to the third script option, Landscape Left.

  5. Press the Spacebar to change the option from On to Off.

  6. Press Tab again to move to the fourth script option, Landscape Right.

  7. Press the Spacebar to change the option from On to Off.

    Duplicate a script step

  8. Press Command-D (OS X) or Control+D (Windows) to duplicate the Set Allowed Orientations step.

  9. Use Tab and Spacebar to change the options so that the two portrait orientations are Off and the two Landscape orientations are On.

  10. Press Shift-Command-Enter (OS X) or Shift-Control+Enter (Windows) to create a new line above this step.

    Add an Else If step

  11. Type the following abbreviation for "Else If": ei  then press Enter.

  12. Type the following Else If condition: $orientation = "landscape"  then press Enter.

  13. Press the Down Arrow to move down one script step.

  14. Press Command-Enter (OS X) or Control+Enter (Windows) to create a new line.

    Add the last two steps

  15. Type the following abbreviation for "Else": el  then press Enter.

  16. Press Command-Enter (OS X) or Control+Enter (Windows) to create a new line.

  17. Type the following acronym for "Set Allowed Orientations": sao  then press Enter.

    The script step is added with its options set to allow all four orientations, which is what you want.
    The script is complete!

    Save and close your script

  18. Compare your script to the finished one to confirm that it’s correct.

  19. Press Command-S (OS X) or Control+S (Windows) to save your script.

  20. Press Command-W (OS X) or Control+W (Windows) to close the script.

  21. Close the second window that contains the finished script.



Code more flexibly

Consider writing a more flexible script that receives the text equivalent of a 4-bit binary value (like "1100") as its parameter, representing the "On/Off" values for each of the four allowed orientations. Expand your series of "Else If" statements to handle each possible combination of orientations. Although the parameter could have 16 different values, only 15 of them are relevant. The value "0000" (where all four orientations would be set to "Off") can't be used because at least one orientation must be permitted.

A version of this script is included in the example solution: