Event Explanation
What is an Event?
An event in Pragmatic Studio is a block of code that executes at a specific moment within a form. Unlike data sources, which return data to be displayed in the form, events are not designed to return data; instead, they execute specific actions in response to certain execution moments within the form.
The main difference between an event and a data source is that while the data source is designed to return an array of data for use in the form, the event is executed to perform actions without the need to return data.
Events can execute JavaScript functions, perform queries or insertions into MongoDB or SQL databases. They can also use parameters to retrieve data from the form if necessary.
Components
Event List
In this section, users can view all previously defined events. Each event is presented clearly and in an organized manner, making it easy to identify and select the desired event for viewing or modification.
Search Filter
Users can use a search filter by event name to quickly find specific events.
Creating a New Event
To create a new event, users simply need to click the create button located in the interface. This will open an interface that guides them through the process of designing and configuring the new event, allowing customization according to their specific needs.
Events can be created to process data either in an SQL database, a MongoDB database, or using a JavaScript function.
Execution mode
When creating a event, it’s important to define its execution mode, as this will determine how the event behaves in relation to the form instances that use it:
Current version: When this option is selected, all form instances using this event will always access its most recent version. This means that any modification made to the event will be immediately reflected in all instances that use it, even in those that existed before the modification.
Historical version: When this option is chosen, each form instance will maintain a copy of the event as it was at the time of its creation. This means that subsequent modifications to the event will not affect existing instances, as each one will preserve the version of the event that was in effect when it was created. This option is useful when you need to maintain historical data consistency or when event modifications should not affect existing instances.
Modifying Events
Users also have the ability to edit existing events as needed. They can access the edit options for a specific event by clicking on it in the event list and making the necessary modifications. To learn more about how to modify an event, click here.
