Save Handlers

Intro

Save handlers are classes that allow to run code before or after saving a record. They similar to the legacy before_save and after_save logic hooks.

Mappers have been added to allow for more flexibility when extending SuiteCRM.

They are split into type and modes, there are:

Types: - Field - Field Type - Record

Modes: - before-save - after-save - save

Mapper Types

There are 3 mapper types for Save handlers:

Field Mapper

Field Save Handlers are only executed for the specified module and field. This is useful when you want to modify the data of a specific field (e.g. phone_mobile on Accounts).

Field Type Mapper

Field Save Handlers are executed for all the fields of a given type and for the specified module. This is useful when you want to add a generic transformation to all fields of a given type (e.g. datetime on Accounts).

Record Save Handler

Record Save Handlers is executed at the "record scope", it is possible to change any number of fields for module at the same time. This is useful when you want to modify multiple fields at the same time.

Save Handlers Modes

Save handlers modes allow you to specify when the mapper should run. One or more of the following modes can be set: before-save, after-save.

Before-save

This mode is called on the SuiteCRM 8 side before saving a record.

After-save

This mode is called on the SuiteCRM 8 side after saving a record.

Other configurations

Save Handler Order

When adding a new Save Handler you will have the getOrder function to set the order/ priority in which the mappers run per mapper type.

Content is available under GNU Free Documentation License 1.3 or later unless otherwise noted.