Cannot Email Report On Demand

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • d1m17ar
    Junior Member
    • Sep 2025
    • 5

    #1

    Cannot Email Report On Demand

    When trying to mail a report instantly
    Click image for larger version

Name:	image.png
Views:	0
Size:	23.0 KB
ID:	127977

    we're getting the following error:

    Code:
    [2026-09-16 06:32:20] DEBUG: API (403) Cannot link an already linked attachment (Email:attachments).; POST /Email; Route pattern: /{controller}; Route params: Array ( [controller] => Email [action] => create )
    [2026-09-16 06:32:20] NOTICE: (403) Cannot link an already linked attachment (Email:attachments). :: POST /Email
    [object] (Espo\Core\Exceptions\ForbiddenSilent(code: 403): Cannot link an already linked attachment (Email:attachments). at /var/www/html/application/Espo/Core/Exceptions/Forbidden.php:62)

    I tracked it to Espo\Modules\Advanced\Tools\Report\SendingService. php

    PHP Code:
    if ($attachmentId) {
        $data->attachmentId = $attachmentId;
    
        $attachment = $this->entityManager->getEntityById(Attachment::ENTITY_TYPE, $attachmentId);
    
        if ($attachment) {
            $attachment->set([
                'role' => 'Attachment',
                'parentType' => Email::ENTITY_TYPE,
                'relatedId' => $id,
                'relatedType' => ReportEntity::ENTITY_TYPE,   // <-- this is the problem
            ]);
    
            $this->entityManager->saveEntity($attachment);
        }
    }
    Could you please take a look. Thanks.
Working...