This activity adds an event handler to a Form Element at runtime. This is especially useful when you add the Form Element via the Add Form Element activity since there is no way to configure events for such Form Elements in the Designer. However, you can also use this activity for Form Elements that you add in the Designer.
This activity replaces any existing event handler for the specified event on the specified Form Element.
You could use an Add Form Element activity to add a new Text Box element to a form at runtime and then use Set Form Element Event to add an event handler to handle its "validate" event.
You must also add a Container or Try Catch activity which contains the subworkflow to be executed when the event takes place.
Display Form Id |
Optional Type: String The ID of the Display Form activity that contains the element to add the event to. If not specified, the form that contains the element that triggered the subworkflow is used. You can use the "activities" object in an expression to specify the ID of an activity, such as "=activities.form1". This can help avoid typos, and warns you if it is wrong. |
Element Name |
Optional Type: String The ID of the form element to apply the event to. If not specified, the form element that triggered the subworkflow is used. If no element is found, the activity will fail with an error. |
Event Name |
Required Type: String The name of the event to add to the Element. |
Target Activity Id |
Required Type: String The ID of the activity to use as the event handler. This can be a Container or Try Catch. You can use the "activities" object in an expression to specify the ID of an activity, such as "=activities.tryCatch1". This can help avoid typos, and warns you if it is wrong. |
This activity has no outputs.
For information about the ID, Display Name, and Description properties, see Properties Common to all Activities.
This example demonstrates how to use the Set Form Element Event activity to dynamically bind an event listener to a form element. When a user selects an option from a Drop Down List, the changed event triggers an isolated Container subworkflow that updates a map layer's definition expression in real time.
In VertiGIS Workflow, event-handling subworkflows do not sit in the main sequential flow—instead, they reside in standalone (unconnected) containers that act like background callback functions. The Set Form Element Event activity serves as the bridge between the form element and this container, firing the subworkflow only when the specified user interaction takes place.
When to use this pattern:
While you can configure events directly in the Form Designer for static elements, the Set Form Element Event activity is essential when you generate elements dynamically at runtime (using Add Form Element).
Specifically, this example will use the following:
•a Buildings layer named "Buildings"
•the building type named "Actual_Use"
•A Get Map activity
•A Display Form activity with a drop down list.

To filter a layer when a drop down selection changes:
1.Add a Get Map activity to your workflow (id = getMap1).
2.Add a Display Form activity to your workflow (id = form1).
3.Add a Drop Down List to the form (id=dropDown1).
4.Add valid options to the list:
oASPHALT PLANTS
oAUTOMOBILE DEALERSHIP
oAUTOMOBILE PAINT SHOP GARAGES ETC
oBANK
5.(OPTIONAL) Uncheck the Visible checkbox for the Button Bar.
6.In the form's Header > Events > load:
a.Click Edit to add a Set Form Element Event activity.

b.Set Element Name to the ID of the dropdown element, in this case, dropDown1.
c.Set Event Name to changed.
d.Set Target Activity ID to =activities.layerFilterContainer.
Using the activities object instead of just writing layerFilterContainer means this expression will automatically be updated if the layerFilterContainer activity is renamed in future.
7.Drag a Container activity onto the workflow design canvas (outside the main linear sequence):
a.Set the ID of the Container to layerFilterContainer.
8.Double-click layerFilterContainer to edit its subworkflow:
a.Connect a Set Property activity to the container's Start activity.

b.In the Inputs secton, set Object to
=$getMap1.map.map.allLayers.items.find(l => l.title === "Buildings").
c.Set Property Name to definitionExpression.
d.Set Property Value to
="Actual_Use = '" + $form1.state.dropDown1.value + "'".
When the workflow runs, the form renders with the dropdown element. Whenever the user changes the selected dropdown option, the changed event fires, executing the subworkflow inside layerFilterContainer to update the map layer's filter in real time.

This activity works when the device has intermittent connectivity to the network.
See also...