Define map events
Summarize
Summary of Define map events
Event mapping in ServiceNow's UI Builder allows you to connect an event's payload or context to the object or handler that processes the event. This process is critical for enabling components on pages to perform actions in response to user interactions or system changes. For example, mapping a button-clicked event to an event handler lets you define what happens when a user clicks a button.
Show less
Event Types
The types of events you can map depend on the component and the scope of the action you want to perform. There are four main event types:
- Component events: Actions tied to individual components, such as a button triggering navigation.
- Page events: Actions affecting the entire page, including page readiness or property changes. These include:
- Page event mappings: Saved on the page definition and include handlers like user session events, page-level events, and data source operations.
- Variant event mappings: Serve as relays for component-dispatched events to user session handlers; created automatically when mapping dispatched events.
- Dispatched events: Custom events created to relay actions, with configurable payload fields, saved in the system event table.
- Handled events: Manually configured events with custom payloads, used as source events for page event mappings.
- Data resource events: Trigger notifications related to data fetch processes, including initiation, success, and failure. These enable handlers to respond to data resource states.
- Declarative action events: Allow binding of data elements to declarative actions within the ServiceNow AI Platform. These are configured via the declarative action assignment table and bound in UI Builder.
Practical Application
As a ServiceNow customer, understanding these event types and how to map them enables you to create responsive and interactive pages in UI Builder. You can configure component-level interactions, manage page-wide behaviors, notify users about data fetch statuses, and integrate declarative AI-driven actions. Event mappings are saved in system tables, ensuring persistence and traceability.
Use component events to control individual UI elements, page events to handle broader page behaviors, data resource events to monitor and react to data operations, and declarative action events to leverage AI capabilities within your applications.
An event mapping in UI Builder is the process that enables you to map an event's payload or contextual values to the object or handler that acts on that event. The four event types are: component, page, data resource, and declarative action.
Event mapping is an important process within UI Builder. When you build pages with components, you need those components to perform actions for users. For example, if you add a button component to the page, a button-clicked event must be mapped to an event handler. The event handler performs a button-clicked action when it is selected by a user. An example is when you add a data resource, such as a form, and have an event handler notify the user when the form successfully loads.
Event types
The event types that are available are based on the component. For example, declarative action events are available for specific components, such as the Action bar and List components.
You choose a type of event based on what action you want to perform on your page. For example, if you want to bind an action to a component, such as a button loading a web page, you would use a component event. If you want an event to apply to your whole page, such as adding an alert notification to a page, you use a page event. The following table describes each event type that is available in UI Builder and provides some examples on how you can use the events.
| Event type | Description |
|---|---|
| Component events | Action that you set up for a component. You set up an event handler to configure that component action. For example, add an event handler to apply an action for a button, such as going to a web page. For more information on binding events to components, see Bind an event to a component. |
| Page events | Page event that performs an action for the entire page. You can configure the following page events:
|
| Data resource events | Events that are mapped to data resources to provide notifications about when data is fetched.
|
| Declarative action events | Bind data elements within UI Builder to add event actions to a declarative action. You configure a declarative action event mapping in the ServiceNow AI Platform® declarative action assignment table. For an example, navigate to and then search for and open an existing declarative action. In UI Builder, you bind an event to the declarative action. For more information on how to use declarative action events, see Bind an event to a declarative action. |