A standard form interface element is the checkbox, or on iOS, the switch. The value of this form element is a boolean of either true or false.
The following describes how to add checkboxes to forms.
checkSwitchField = new Form.Field.Checkbox(
"The label for the element",
checkSwitchField = newForm.Field.Checkbox(
key:String, <-- identifying key used in the form values record
displayName:String or null, <-- field label for the form dialog
value:Boolean or null<-- an optional default value for the field
1 Instances of the form checkbox/switch input element are created using the new constructor with provided parameters that include the identifying key, an optional menu label (title), and an optional default string value or the field. The result of the constructor is a new instance that is stored in the variable: checkSwitchField
2 The form element is assigned a unique identifying key (string) that is used to extract the current displayed checkbox object when the form is validated or processed.
3 The optional text to use as the label for the menu.
X An optional default boolean value for the checkbox/switch.
Simple Example Console Script
The following is an example of to create, display, and process the results of a form with a single text input field. As the script example is not placed within an Omni Automation action framework, this type of script is best run from either the console or a script URL.
checkboxSwitch = new Form.Field.Checkbox(
"Append the imported text to the existing text",
var inputForm = new Form()
01-05 The creation of a new instance of the Form.Field.Checkbox (checkbox/switch) class. Note the inclusion of the identifying key string "checkboxSwitch" that is used elsewhere in the script to retrieve the current input value of the form element.
06 A new empty instance of the Form class is created and stored in the variable: inputForm
07 The created checkbox/switch is added to the form using the addField(…) method of the Form class.
10 The callback function within the then(…) method is passed the form object as its parameter.
11 Using the checkbox/switch’s identifying key, the current boolean state of the field is retrieved from the record returned as the value of the passed form’s values property. Any processing of the retrieved data by the script would be placed in the scrpt statements following this one.
This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.