Announcement

Collapse
No announcement yet.

E-Mail Notification assigned task not working

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

  • E-Mail Notification assigned task not working

    E-Mail Notification for an assigned task is not working at all under this circumstances:

    Steps to reproduce (EspoCRM 7.4.6)

    1) User Prefences the following hooks are set:
    - ​Email notifications upon assignment
    - Email notifications about mentions in posts​
    - Email assignment notifications (all set, including tasks)

    User Prefences the following hook is not set:
    - Email notifications about posts and status updates

    2) Create a new task and assign it to an other user than yourself who has set the hooks as described

    The "Espo\Tools\EmailNotification\Jobs\NotifyAboutAssi gnment" Job is not created for tasks.

    Info: For other entities (opportunties, calls, case) it is created correctly.

    If the hook for "Email notifications about posts and status updates" is set true then the Job "Espo\Tools\EmailNotification\Jobs\NotifyAboutAssi gnment" is created for tasks, too.

    Workaround could be designing a BPM for sending E-Mail notification for tasks.
    Same was described here I think:
    When creating a "New" Task or Case, email is not being send to the contact person upon creation, I need the contact person to be notified when a case or task is created for his "Account". It just works when a stream is updated, example when closing a case. i just wanted to know if this is a actual issue or


  • #2
    Could you please send screenshots of the settings from Administration > Notifications (screenshot 1) and from Preferences > User_Name > Notifications (screenshot 2)?

    Info: For other entities (opportunties, calls, case) it is created correctly.
    So Notifications don't work only for entity Task?
    Attached Files

    Comment


    • #3
      So Notifications don't work only for entity Task? --> Yes. It works for other entities but not for tasks.
      Attached Files

      Comment


      • #4
        FYI:
        I designed a Workaround with Formula (before save), a new Boolean Field and an BPM Workflow.

        Task:
        ifThen(assignedUser.emailAddress!=null && entity\isAttributeChanged('assignedUserId') == true && entity\attribute('assignedUserId') != createdById && entity\attribute('assignedUserId') != modifiedById, mailsenden = true);

        BPM:
        Send E-Mail if "mailsenden == true", afterwards reset "mailsenden = false". Meanwhile unhide a red colored Panel with text and set write-only for field "assigned user" as field condition to inform the users while BPM is working. (Both defined if "mailsenden == true"). Because of if you change "assigned User" twice meanwhile before the BPM sends the E-Mail (every 2 Minutes), the wrong user could probably get the E-Mail. And the Workflow isn't triggered parallel if the "old" one didn't finish.

        Have to wait max 2 Minutes and refresh the Browser (F5). The layout does not refresh itself because BPM doesn't support Websockets as far as I know.
        Last edited by macistda; 06-15-2023, 02:24 PM.

        Comment


        • #5
          FYI, the "Bug" is present at Espo 7.5.1, too.

          Comment


          • #6
            Please try step by step.

            - To disable all the ticks related to notifications, also remove everywhere the entity Task (which is present on your screenshots) and save the changes -> make Rebuild -> enable all the ticks related to notifications, also remove everywhere the entity Task (which is present on your screenshots ) -> make Rebuild again.​
            - Check the formulas, BPMs and Workflows you use with the entity Task and Email. Try to disable them all and test the work of Email notifications.
            - You can try the following:
            1. Make a full backup of your current EspoCRM instance and keep it in a safe place: https://docs.espocrm.com/administrat...p-and-restore/.
            2. Delete the EspoCRM files from your hosting.
            3. Install clean EspoCRM v7.5.1 instance. During installation, select your old database.
            4. Delete /custom and /data folders from new instance and copy these folders from backup to the new instance.
            5. Run Rebuild from CLI.​​

            Last edited by victor; 06-16-2023, 11:51 AM.

            Comment


            • macistda
              macistda commented
              Editing a comment
              I am pretty sure (many years of experience) that there is something missing / a bug, because "Espo\Tools\EmailNotification\Jobs\NotifyAboutAssi gnment" -Job is not created under the written circumstances and it depends on that hook(s), even for the "create" event, and that can't be the planned programming I think.
              Your suggested try, especially the 2nd part is a little bit "overpowererd" for me, but thank you anyway. We have a 2nd instance for testing purposes and the behavior is the same.

          • #7
            I would not recommend to delete and re-install Espo. It's too much of a hassle to solve the minor problem. Better to figure out what causing the problem and fix.

            Comment


            • #8
              Do you have multiple assigned users field created for Task?

              Comment


              • macistda
                macistda commented
                Editing a comment
                yes, the "normal" one (assigned user) and one additional multiple link field.

            • #9
              Note that if in-app notification has been read by a user, and a corresponding email notification is not yet send (there's a configurable delay period), an email notification won't be sent. It's an intentional behavior.

              Comment


              • #10
                Click image for larger version

Name:	ent_task.png
Views:	421
Size:	34.0 KB
ID:	93991
                Screen

                Comment


                • #11
                  You can try to debug here https://github.com/espocrm/espocrm/b...cessor.php#L60

                  Put
                  PHP Code:
                  if ($entity->getEntityType() === 'Task') {
                      
                  $GLOBALS['log']->error('1');

                  with incremental numbers in different places to know where code exits.

                  Comment


                  • #12
                    Hi macistda,

                    I can say with confidence that this is definitely not a bug in the system. For the Task entity, in vanilla EspoCRM v7.5.1 with notification settings like yours, I checked the functionality of notifying users by email that Task was assigned to them, and everything worked correctly. I am attaching screenshots where you can see the time (you need to look at the minutes), where you can see that the job worked and the email came less than in a minute:

                    Click image for larger version  Name:	Screenshot from 2023-06-16 15-22-05.png Views:	0 Size:	9.6 KB ID:	94000

                    Click image for larger version  Name:	Screenshot from 2023-06-16 15-21-50.png Views:	0 Size:	17.2 KB ID:	93999

                    Feeling that it's all about some additional settings (formulas, workflows, BPM, changes in EspoCRM files).

                    Try installing a clean latest version of EspoCRM, without any modifications, on your server and reproduce the problem.​
                    Last edited by yuri; 06-16-2023, 03:09 PM.

                    Comment


                    • #13
                      Originally posted by yuri View Post
                      You can try to debug here https://github.com/espocrm/espocrm/b...cessor.php#L60

                      Put
                      PHP Code:
                      if ($entity->getEntityType() === 'Task') {
                      $GLOBALS['log']->error('1');

                      with incremental numbers in different places to know where code exits.

                      This variable is not filled if type == task. ($entity->isAttributeChanged('assignedUserId'))



                      Our debug code:
                      PHP Code:
                      $userId $entity->get('assignedUserId');

                      $GLOBALS['log']->error("3. Entity: {$entity->getEntityType()}, User: {$userId}, X: {$entity->isAttributeChanged('assignedUserId')}, Y: {$this->isNotSelfAssignment($entity$userId)}");

                      if (
                      !
                      $userId ||
                      !
                      $entity->isAttributeChanged('assignedUserId') ||
                      !
                      $this->isNotSelfAssignment($entity$userId)
                      ) {
                      return;
                      }

                      if (
                      $entity->getEntityType() === 'Task') {
                      $GLOBALS['log']->error('Task 4');
                      }
                      ​ 
                      Logfile:
                      ...
                      [2023-06-19 11:54:27] ERROR: 3. Entity: Task, User: 60c54685991272cda, X: , Y: 1
                      ...​

                      We tried with a case and X was filled correctly ('1').

                      Comment

                      Working...
                      X