Universal Read Hook.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xdr21
    Junior Member
    • Oct 2024
    • 3

    #1

    Universal Read Hook.

    Hello,

    I’m working on an extension that allows me to encrypt specific fields in the database using EspoCRM’s native encryption. So far, I’ve successfully implemented encryption across any entity where fields are marked for encryption in the Entity Manager.

    The issue I’m facing now is decrypting those fields on the server side before they’re displayed to the user. I tried using a ReadHook, but those appear to be entity-specific.

    Does anyone know a way to trigger a hook universally—without specifying a particular entity? I want decryption to work across all entities as long as a field is flagged as encrypted. However, I haven’t been able to find a suitable trigger to execute the decryption code.

    For reference, I’ve already implemented the beforeSave hook globally for encryption without any issues.

    Thanks in advance for any insights!
  • yuri
    EspoCRM product developer
    • Mar 2014
    • 9485

    #2
    Hi,

    The workaround is to amend metadata with an 'additional builder'. When metadata is built, it will patch it so that the Read Hook will be appended for each entity (or for only those that you need). It's a robust solution as long the result metadata follows the metadata specs.



    There are few additional builders classes in the codebase you can use as examples.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    Working...