Trigger events when removing contacts (change linked custom entities)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Pieter
    Junior Member
    • Jan 2022
    • 2

    Trigger events when removing contacts (change linked custom entities)

    First things first, Espo CRM is a wonderful CRM. Thanks to the custom modules it can configure to be much more than that... Wonderful.

    I ran into an issue though that I hope someone can help me with.

    I created a custom entity: Membership. Every contact can have one or more memberships. I would like to be able to update memberships to "deleted" whenever a contact is removed. How would I do that?
  • esforim
    Active Community Member
    • Jan 2020
    • 2204

    #2
    Paid option would be Workflow...

    Free option... not sure if it possible. You can change a field call "status" to "delete"; Status: Delete
    using formula, but the record will still be there, it can't be automated delete. I suppose you can add in a visibility condition where most user can't see it except for certain group/admin... but the record will still be there!

    Comment

    • item
      Active Community Member
      • Mar 2017
      • 1476

      #3



      Contact -> afterRemove


      foreach($memberships as $membership )
      $membership->set(['deleted' => 1]) or removeFromDb. https://docs.espocrm.com/development...delete-from-db






      If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

      Comment

      • Pieter
        Junior Member
        • Jan 2022
        • 2

        #4
        Many thanks! I will try these options and report back over here.

        Comment

        Working...