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.
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);
}
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;
Parameter | Type | Description |
---|---|---|
key | string | The key associated to the value |
value | string | The value to display in the lookup |
Example
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);
}
Figure 2 - Adding the options