Announcement

Collapse
No announcement yet.

Popup notification after Lead assigned

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

  • 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 $entitySaveOptions $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:	220
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


  • #2
    grej this is very coo!

    Comment


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

      Comment


      • #4
        I tried to create a custom one using this




        but it’s not triggering

        Comment

        Working...
        X