Client-side event handler extensions

The aim of this project was to be able to execute pre-save actions as well as post-save actions, thereby improving usability for the user throughout the application.

Those actions could be as simple as showing a message when a new record is saved or updated, or involve more complex actions designed to ease the lives of users.

There are three event types already available: Post-save, Pre-save and Pre-delete.

Here are some use examples for actions that can be executed when some of the previous events are fired:

Post-save Action:

An example of this type of action would be once a record is created in a window, we want to open another tab. This can be done with the post-save action.

Another  example is the ability to refresh the grid after creating or saving a record. This can be also done with a client-side event handler.

Or we may want to display a message after saving a record. Since client event handlers are allowed to identify whether the record is being saved or updated, it is now possible to show a different message, depending on whether we are creating or updating a record.

Pre-save action:

Sometimes it is useful to validate something before saving. Now this can be done by event handlers with the pre-save action.

For example, in the User window there is a field where the e-mail address must be entered. We can now implement an action which checks if the email is valid before saving the record. And if it is not valid, the record will not be saved.

Pre-delete action:

This kind of action was introduced in 3.0PR17Q1 release. It is used to execute an action before deleting a record. It allows the event handler to implement validations (either on the client or server side) to prevent the deletion of a record when that validation is not passed.

Here is an example of code used for a post-save action,  in the case of opening a tab after saving a record in another tab:

OB.OBPFCI.ClientSideEventHandlers.openTab = function (view, form, grid, extraParameters, actions) {
if (extraParameters.isNewRecord) {
// Save flow
OB.EventHandlerRegistry.callbackExecutor(view, form, grid, extraParameters, actions);
OB.OBPFCI.ClientSideEventHandlers.openTab.sort = 120;
OB.EventHandlerRegistry.register(OB.OBPFCI.PRODUCT_CATEGORY_HEADER_TAB, OB.EventHandlerRegistry.POSTSAVE, OB.OBPFCI.ClientSideEventHandlers.openTab, 'OBPFCI_OpenTab');

Check out the available documentation to learn more about this functionality and subscribe to the blog to stay updated with new blogposts describing additional release features.


Previous post

Openbravo´s First Coderetreat Event Was a Success!

Next post


No Comment

Leave a reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>