Nav view search

Navigation

Search

The Exchange

The place to download pre-configured tickets, code snippets, and solutions

Back

Making Static Lists in Global MetaScript for Use in a Form

Use a MetaScript array in the Global MetaScript to create static lists in a form.

Details

By using a MetaScript array in a form's Global MetaScript, a list of items can be generated one time and then reused in multiple Popups in the form. Such a script can save time in much the same way that dynamic popups save time: by reducing the need to manually enter values across multiple popup fields.  

Note: Static lists created in a form's Global MetaScript can only be used in the corresponding form.  To create a static list that can be used in any form, see Toolbox Snippet - Making and Reusing Static Lists in a Stored File for Use in Forms. Also note that this example is provided to illustrate a concept; performance may be impacted if the function contains numerous calculations. 

Example

This example describes how to create a static list in a form's Global MetaScript and use it in a Popup field on a form. To achieve this, perform the following steps:

  1. Open a form in the form editor
  2. Open the Global MetaScript Editor for the form and enter the following text:
    function 
    getList() 
    { 
    var myList = new Array("Joe", "Steve", "Bob", "Sally", "Mike"); 
    return myList.sort(); 
    }

    This Global MetaScript creates the static list every time the function is called by an element within the form.

  3. Create a Popup Field on the form and assign a database field to it using the "Field" selector in the Control Properties panel.
  4. Make the field Editable by selecting "Yes" for the "Editable" value in the Control Properties panel.
  5. Select "MetaScript" in the "Popup is filled by" control in the Control Properties panel.
  6. Type "getList();" in the "List MetaScript" control in the Control Properties panel.
  7. Save the form.
  8. Result: The Popup Field in the form will contain the static list contained in the form's Global MetaScript. By defining the getList() function in the Global MetaScript, this same list may be applied to multiple Popup Fields in the same form.

Resources

Last Modified:

2011-10-05

by

Chris True