Last Contact and Contact number

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jorgeyoma
    Member
    • Mar 2016
    • 46

    Last Contact and Contact number

    Hi.
    I've been using Espo for a while and I suggest to implement this two fields on the Account View:
    - Last Contact Date: whatever it is email, call or meeting. It's really needed.
    - Contacts : contact number.

    The Last Contact date should be implemented in the Contact view also.


    B/R
  • jorgeyoma
    Member
    • Mar 2016
    • 46

    #2
    Hi.
    I've created two fields in the Account Entity to store this data.
    I can create a sql query to update this fields everytime a contact is created or deleted or everytime a "contact event" is registered.

    Can you give me some guidance to run this sqls with hooks?

    Thanks.

    Comment

    • tanya
      Senior Member
      • Jun 2014
      • 4308

      #3
      hi
      Hi, I have created a custom module and now I would like to apply one of the entity hooks to it. From what I can see there is the following hooks: beforeSave

      create hook afterSave for events

      Comment

      • jorgeyoma
        Member
        • Mar 2016
        • 46

        #4
        Originally posted by tanya
        hi
        Hi, I have created a custom module and now I would like to apply one of the entity hooks to it. From what I can see there is the following hooks: beforeSave

        create hook afterSave for events
        Thanks!

        Comment

        • jorgeyoma
          Member
          • Mar 2016
          • 46

          #5
          Originally posted by tanya
          hi
          Hi, I have created a custom module and now I would like to apply one of the entity hooks to it. From what I can see there is the following hooks: beforeSave

          create hook afterSave for events
          Hi Tania.
          I'm a bit confused.

          I should create this :
          custom/Espo/Custom/Hooks/Events/afterSave.php
          or
          custom/Espo/Custom/Hooks/Events.php

          ?

          Comment

          • tanya
            Senior Member
            • Jun 2014
            • 4308

            #6
            Copy of yurikuzn anwer

            Hi

            Use this one as example
            application/Espo/Hooks/Note/Notifications.php

            Create cusom/Espo/Custom/Hooks/{ENTITY_NAME}/HookName.php

            PHP Code:
            namespace Espo\Custom\Hooks\{ENTITY_NAME};

            use Espo\ORM\Entity;

            class HookName extends \Espo\Core\Hooks\Base
            {

            public function afterSave(Entity $entity)
            {
            $meeting = $this->getEntityManager()->getEntity('Meeting');
            $meeting->set('name', 'Hello ' . $entity->get('name')) ;
            $this->getEntityManager()->saveEntity($meeting);
            }

            }

            Clear Cache after that.

            Comment

            • jorgeyoma
              Member
              • Mar 2016
              • 46

              #7
              ...I read it and I didn't understand, thats why I asked...

              Comment

              • alasdaircr
                Active Community Member
                • Aug 2014
                • 525

                #8
                The HookName is not important it's just to distinguish the class. The Folder <ENTITY_NAME> is important - it's how Espo knows which classes to call via the Hook Manager. There's also a Common folder in Hooks which is where classes that should run on every hook are placed.

                So in your case you need

                custom/Espo/Custom/Hooks/Account/NameOfMyHookClass.php

                PHP Code:
                namespace Espo\Custom\Hooks\Account;
                
                use Espo\ORM\Entity;
                
                class NameOfMyhookClass extends \Espo\Core\Hooks\Base
                {
                
                    public function beforeSave(Entity $entity)
                    {
                        parent::beforeSave();
                    }
                
                } 
                

                Comment

                • alasdaircr
                  Active Community Member
                  • Aug 2014
                  • 525

                  #9
                  If you just looked in the folders before asking questions you would see this for yourself..

                  Comment

                  Working...