Custom Classes in 9.0.4

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gpm
    Junior Member
    • Sep 2024
    • 1

    Custom Classes in 9.0.4

    I was running 8.4.2 in a docker install and I moved the installation to a self contained lxc with a more traditional installation. I was able to migrate and then upgrade to 9.0.4 via the cli upgrade method. Espo is operational with all my old data on the new server.

    On the old setup I had a custom class that I wrote to sync contact email, first name, and last name to my keila.io mailing list contacts. Part of the json payload to keila was some custom data so that I could segment users that were added from espo. Was working great on 8.4.2 but when I try to put the same files back in v9 I get a 500 error when saving a contact. The 500 error is on the espo api side.

    I'm registering the hook:
    /var/www/espocrm/custom/Espo/Custom/Resources/metadata/hooks/hooks.json
    Code:
    {
    "Contact": {
    "afterSave": [
    {
    "className": "Espo\\Custom\\Hooks\\Contact\\KeilaSyncHook"
    }
    ]
    }
    }
    And then I have the php function at:
    /var/www/espocrm/custom/Espo/Custom/Hooks/Contact/KeilaSyncHook.php

    If I delete the files, clear the cache, and rebuild things seem to work fine. This is the same setup I had in 8.4.2 without any issues there. Is there a change in the logic on v9 that I need to account for in how I implement this?
    Last edited by gpm; Today, 07:55 AM.
  • a.slyzhko
    Member
    • Oct 2023
    • 99

    #2
    Originally posted by gpm

    I'm registering the hook:
    /var/www/espocrm/custom/Espo/Custom/Resources/metadata/hooks/hooks.json
    Code:
    {
    "Contact": {
    "afterSave": [
    {
    "className": "Espo\\Custom\\Hooks\\Contact\\KeilaSyncHook"
    }
    ]
    }
    }
    Where did you found this information? If you aim to create repository hooks, there is no need to register them in metadata. It was that way even before v9.0 update

    Comment


    • Kharg
      Kharg commented
      Editing a comment
      Usually AI hallucinates and suggests these kind of solutions

    • item
      item commented
      Editing a comment
      lol... and now another IA will copy these snippet code and will give another hallucinates
      This is how IA will be destroyed by himself
Working...