Popup notification after Lead assigned

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • grej
    Junior Member
    • Feb 2024
    • 13

    Popup notification after Lead assigned

    Good day everyone,

    somehow I was able to create popup notifications after lead was assigned to user

    PHP Code:
    <?php
    namespace Espo\Custom\Hooks\Lead;
    use Espo\Core\Utils\DateTime as DateTimeUtil;
    use Espo\ORM\EntityManager;
    use Espo\ORM\Entity;
    use Espo\Core\Hook\Hook\AfterSave;
    use Espo\ORM\Repository\Option\SaveOptions;
    class Notification implements AfterSave
    {
        private EntityManager $entityManager;
        public function __construct(EntityManager $entityManager)
        {
            $this->entityManager = $entityManager;
        }
        public function afterSave(Entity $entity, SaveOptions $options): void
        {
            $user_id = $entity->get('assignedUserId');
            if($user_id){
                $notification = $this->entityManager->createEntity('Notification', [
                    'data' => [
                        'entityId' => $entity->get('id'),
                        'entityName' => $entity->get('name'),
                        'entityType' => 'Lead',
                        'userId' => 'system',
                        'userName' => 'System',
                    ],
                    'type' => 'Assign',
                    'read' => false,
                    'emailIsProcessed' => false,
                    'message' => 'Lead assigned',
                    'userId' => $entity->get('assignedUserId'),
                    'relatedId' => $entity->get('id'),
                    'relatedType' => 'Lead',
                ]);
                $popup = $this->entityManager->createEntity('Reminder', [
                    'remindAt' => date(DateTimeUtil::SYSTEM_DATE_TIME_FORMAT),
                    'startAt' => date(DateTimeUtil::SYSTEM_DATE_TIME_FORMAT),
                    'type' => 'Popup',
                    'entityId' => $entity->get('id'),
                    'entityType' => 'Lead',
                    'userId' => $entity->get('assignedUserId'),
                ]);
            }
        }
    }
    this is how it looks

    Click image for larger version

Name:	image.png
Views:	233
Size:	12.8 KB
ID:	103166

    but I have stuck with editing this popup, can someone explain how to make it render some text value inside instead of endDate (which is now None).

    I have made Reminder {"customizable":true}, added field Message, but it obviously was not rendered in popup

  • crmclients
    Senior Member
    • Jul 2020
    • 254

    #2
    grej this is very coo!

    Comment

    • grej
      Junior Member
      • Feb 2024
      • 13

      #3
      Should I create a new Entity from the scratch, or there is some way around?

      Comment

      • Kharg
        Senior Member
        • Jun 2021
        • 410

        #4
        I tried to create a custom one using this




        but it’s not triggering

        Comment

        Working...