Creating before-save hook in SuiteCRM 8

Hi, I am new to the SuiteCRM ecosystem,
I would like to find out how I can create a before-save hook, I have tried to add a processhandler in defaultExt, but I am not sure if this is the way to do it.
How does a handler get registered in recordSaveHandlerRegistry?

Thanks in advance!

Welcome :smiley:

1 Like

You’re confusing two very different mechanisms.

Hooks are a v7 mechanism, they’re probably what you’re looking for here.

Process handlers are a v8 mechanism, and they are not necessarily tied to record saves.

Process Handler

Thanks for the reply, eventually figured it out, I have to create a file in defaultExt/modules/Accounts that implements RecordSaveHandlerInterface, it seems the dependency injection takes care of the rest.

Also suggest we update the documentation to reflect this, as it is not very clear, happy to help there if needed

On the page, you can see Edit this page option. Click on it and create PR.

https://docs.suitecrm.com/community/contributing-to-docs/

hey man, could you show us how you made it to work ?

This would me & a lot of others I assume, trying to get my custom verification code to work here :slight_smile:

Hi,

We’ve done this here with a two step process:

  1. Custom save button (angular) - this basically takes the place of the basic save process but calls a custom backend process first.
  2. backend process takes in the record and “validates” it, and returns appropriate messages if necessary and if wrong.
  3. the custom button deals with the returned data and messages, if all okay it then calls the standard save function.
  4. Hide the original save button.

Regards

Mark