Skip to main content

FormField

Last updated 3/12/2024

FormField Object

The

FormField
object allows access to additional functions and properties of a specific field on a form.

Functions

If a field is using a _LookupCustom display type, the following functions are available.

clearOptions()

The

clearOptions()
function clears all options that are currently assigned to the lookup custom control.

JavaScript
Clearing the options for the lookup custom control in the form field

function PopulateAllergies(five, context, result) {
const sender = five.sender();
const allergyNoticeField = sender.tabs[0].dataManager.getFormFieldTypeByID('AllergyNotice');
allergyNoticeField.clearOptions();
return five.success(result);
}


Clearing the options
Figure 1 - Clearing the options

addOption()

The

addOption()
function adds additional options to the lookup custom control which can be selected by a user at runtime of your application.

Available

Client

Function Signature
addAttachment(key: string, value: string) : void;

ParameterTypeDescription
key
stringThe key associated to the value
value
stringThe value to display in the lookup

Example

JavaScript
Adding the options to the lookup custom control in the form field

function PopulateAllergies(five, context, result) {
const sender = five.sender();
const allergyNoticeField = sender.tabs[0].dataManager.getFormFieldTypeByID('AllergyNotice');
allergyNoticeField.clearOptions();
allergyNoticeField.addOption('milk', 'Milk');
allergyNoticeField.addOption('fish', '(e.g., bass, flounder, cod)');
allergyNoticeField.addOption('crus', 'Crustacean shellfish (e.g., crab, lobster, shrimp)');
allergyNoticeField.addOption('tree', 'Tree nuts (e.g., almonds, walnuts, pecans)');
allergyNoticeField.addOption('pean', 'Peanuts');
allergyNoticeField.addOption('whet', 'Wheat');
allergyNoticeField.addOption('soy', 'Soybeans');
allergyNoticeField.addOption('ses', 'Sesame');
return five.success(result);
}


Adding the options
Figure 2 - Adding the options