Administration Guide

Adding Virtual Fields on Forms

Virtual fields are temporary fields for passing transient data to programmable operations of the Action that uses the Form. You can add a virtual field on the Action Form as follows:

  1. Click New > Field. The Form Field dialog box opens.
  2. Click Virtual Field and type a field name.
  3. Select the data type from the Type list.

    INFO: For details, see Virtual Field Types.

  4. For Reference fields: Select an object class which will be the source of reference objects available for selection. You can also select a group of classes such as All Tickets or a group of configuration entities such as Work Calendars.

    For example, to display a list of persons, select Person, as illustrated below. The virtual field will contain a reference to the selected Person record as its value. That will allow you to use that Person’s properties in the business logic, for example to send E-mail Notifications to the person’s primary e-mail address.

    If you want to display a list of object classifiers, select [Object Class] -> [Classifier]. For example, to display a list of Work Order priorities, select Work Order -> Priority. The virtual field will contain a reference to selected priority as its value, and you can use this in a Function for updating Work Order fields.

    NOTE: When used in SQL expressions and scripts, your virtual field will insert the primary key which uniquely identifies the object record in the database. When used in text, the virtual field will insert the object name.

    You can further filter this list to display only certain items, see instructions on building a filtering expression below.

  5. For Lookup fields: Add values for the lookup list as follows:
    1. Click the ellipsis button in the Lookup values field to bring up the Lookup Values dialog box.
    2. Specify whether you want to display a static list of fixed values or to retrieve values from the database:
      • For a static list of values:
        1. Depending on your choice, select either Static list of values (Radio Buttons) or Static list of values (Drop Down) from the Source field.

          NOTE: The Static list of values (Radio Buttons) field appears on the Form as a group of radio buttons, where the field name is the group label. The Static list of values (Drop Down) field appears as a drop-down list.

        2. Click New to bring up the Add Lookup Value dialog box.
        3. Type a value.

          Repeat steps 1-2 to add other list items as needed.

        4. To arrange items in the list, use Move Up and Move Down buttons.
      • For a list of values from the database:

        In the Source field, select Dynamic list based on custom SQL. Then enter a custom SQL query to retrieve from the Alloy Navigator database the data that the lookup list will show. The following two types of SQL queries are allowed:

        • A SQL query that returns two columns. The first column contains field values and the second column contains text items that will be displayed in the drop-down list on the Form. For example, to display a list of persons to be notified via e-mail, use the following query:

          select [Primary_Email], [Full_Name] from [Persons] where [Primary_Email] is not null

          The virtual field will have the primary e-mail address of the selected person as its value.

        • A SQL query that returns one column. This column’s values will be used both as display options and to assign selected value. Single-column queries, while legitimate, offer little practical value.

          NOTE: If your SQL query returns more than two columns, the lookup field will use only the first two columns. Other columns will be ignored.

          You can insert a field or macro in your query by selecting one and clicking Insert at the bottom of the dialog box.

          INFO: For details, see Inserting Placeholders.

    1. Click OK.
  6. Type a field label in the Label field. If you want to use the field name as the label, leave the Label field blank.
  7. If you want to assign an initial value to the field, enter the value in the Value field:
    1. To assign a static value, depending on the field type:
      • select a value from the list,
      • select a date and time from the calendar,
      • calculate a value using the pop-up calculator.

      INFO: For details, see Text Expressions.

    2. To specify a dynamically calculated value, click the Build Expression button to bring up the Build Expression dialog box. Then use the Expression Builder to specify how the calculated value should be formed.

      For example, to insert the Incident requester’s name, create a simple SQL expression, which consists of a single placeholder for the object field value, as illustrated below.

      INFO: For details, see SQL Expressions and SQL Scripts.

      NOTE: The expression or script must return a value of the same data type as the field type. For details and instructions, see Using the Expression Builder.

      NOTE: For virtual lookup fields:
      When your lookup list is based on a SQL query, you can specify the initial field value only by entering an expression or a script. Your expression or script must return a single value of the same data type as the first column of the lookup list’s SQL query.

  8. For Reference fields: If you want to filter out certain items from the drop-down list, click the Build Expression button in the Filter field and create a filtering expression.

    INFO: For details and instructions, see Filtering Out Lookup List Items on Forms.

  9. To specify a hint, enter your text into the Hint field (for illustration, see A dialog-style Form:).
  10. To make the field either mandatory or read-only, select corresponding check boxes under Options.
  11. Click OK.