Announcement

Collapse
No announcement yet.

beforeSave / hooks for related entites

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • beforeSave / hooks for related entites

    Hello I know how to use Service::beforeSave etc to update properties of an entity during the save process, However, how would I update an entity when related entities are removed / added ?

    An example would be Meeting::entryCount which counts the number of entities attending a meeting. This should reflect the number of related entities. So if I remove a contact, entryCount should decrease by 1.

  • #2
    In the next version it will be possible to add afterRelate and afterUnrelate to repository class. It's already there but not sure if it works proper now.

    Comment


    • #3
      Great - I'll have a look. Thanks Yuri.

      Comment


      • #4
        But if you need it to catch after record created it won't work. There is already hook that catches this situations. It creates Note after related record created.

        Comment


        • #5
          hmm yes I'd need it for any state of the record, before creation or after creation. I'll have a look at it as it stands, and the Note hook.

          Comment


          • #6
            Originally posted by yurikuzn View Post
            In the next version it will be possible to add afterRelate and afterUnrelate to repository class. It's already there but not sure if it works proper now.
            When will be these hooks available?

            Comment


            • #7
              Hi
              Already are. Look at /application/Espo/ORM/Repositories/RDB.php
              (an example - relation between KnowledgeBaseArticles and Cases (code is in Repositories))

              Comment

              Working...
              X