Nav view search

Navigation

Search

The Exchange

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

Back

Sorting a Static List with MetaScript

Use MetaScript to sort static lists.

Description

Arrays can be used in MetaScript to generate a static list to be used in Virtual Ticket popup menu fields. A static list would be used in situations where a SQL Query will not produce the list of items because they aren't stored anywhere in the database. Keeping your list sorted in alphabetical order requires the correct MetaScript sorting parameter to keep the list sorted correctly while the list continues to grow. 

Example 

This example demonstrates how to sort a static list that has been generated by a MetaScript array.

  1. Open a form in the form editor.
  2. Open the Global MetaScript Editor.
  3. Enter the following script into the Global MetaScript Editor:
    function 
    getList() 
    { 
    var myList = new Array("Joe", "Steve", "Bob", "Sally", "Mike"); 
    return myList.sort(); 
    }
  4. Create a popup field control on the form and assign a database field to it in the Field selector of the Control Properties panel.
  5. Make the field Editable by selecting "Yes" for the "Editable" value in the Control Properties panel.
  6. Select "MetaScript" in the Popup is filled by control of the Control Properties panel.
  7. Type "getList()" in the List MetaScript control of the Control Properties panel.
  8. Result: When the form is opened and the popup field is selected, the entries in the popup will appear in the following order:
    • Bob
    • Joe
    • Mike
    • Sally
    • Steve

Resources

Last Modified:

2011-10-05

by

Chris True