Skip to main content

On List Select

Last updated 30/11/2021

On List Select Event

The OnListSelect event executes on the client.

Function Signature
OnListSelect(sender, context, result) : FiveError;

ParameterTypeDescription
senderFormFieldAn instance of the form field object.
contextMap<string,any>Optional map of string to values.
resultFiveErrorA Five error to set the result and return the error.

Description

When a user makes a selection from the lookup list, the event will be detected and the code will execute.

Selection From a Lookup List
Figure 1 - Selection from a lookup list

Example

In the Portfolio application, the Buys field has a lookup list in the Stock field. We can write a function and attach it to the Stock field's On List Select event to reset the Quantity, Price, Fees and Total fields if a new selection is made in the Stock field lookup list.

The below function is perfoming the following:

  • Uses the sender parameter on the form to retrieve the fields Quantity, Price, Fees and Total.
  • Will reset the fields Quantity, Price, Fees and Total to zero.

function resetBuysForm(sender: any, context: any, result: FiveError) : FiveError {
let form = sender.form;
form.Quantity = 0;
form.Price = 0;
form.Fees = 0;
form.Total = 0;
return five.success(result);
}

Prerequisites

  • Function must be saved in the Functions view.
  • Form must be saved in the Forms view.

Steps to Attach a Function to the On List Select Event

  1. Select Forms in the menu.
  2. Select the required form record in the list.
  3. Click the Pages tab.
  4. Select the required form page record.
  5. Click the Fields tab.
  6. Select the required form field record.
  7. Click the Events tab.
  8. Click the Edit button in the form app bar.
  9. Use the lookup icon in the On List Select field and select the Function ID.
  10. Click the Save button in the form app bar.
  11. Click both Save buttons in the stacked form app bars.
Attach Function to the On List Event
Figure 2 - Attach a function to the On List event