Add file (Note) to Contact Stream

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • item
    Active Community Member
    • Mar 2017
    • 1476

    Add file (Note) to Contact Stream

    Hi,
    in a sheduled Job, I want unzip a document and these contains many csv file.
    All here is OK.

    But, how I can create Note (?) and relate this to contact ? So ?

    $entityManager = $this->getEntityManager();

    $note = $entityManager->getEntity('Note')

    How put file ?

    $entityManager->saveEntity($note);

    $entityManager->getRepository('Contact')->relate($contact, 'notes', $notes);

    Can be do able ? Where can find help ? Thanks Regards
    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​
  • item
    Active Community Member
    • Mar 2017
    • 1476

    #2
    Strange,

    When I creat a note and a attachment, why parent_id and parent_type is not filled ? all other field are filled.

    Regards.

    PHP Code:
                        $attachment->set(array(
    
                                               'name' => $fileName,
    
                                               'deleted' => 0,
    
                                               'type' => filetype($pathToFile),
    
                                               'size' => filesize($pathToFile),
    
                                               'source_id' => null,
    
                                               'field' => 'attachments',
    
                                               'role' => 'Attachment',
    
                                               'storage' => null,
    
                                               'storage_file_path' => null,
    
                                               'global' => 0,
    
                                               'parent_id' => $noteId,
    
                                               'parent_type' => 'Note',
    
                                               'related_id' => null,
    
                                               'related_type' => null,
    
                                               'created_by_id' => 'system',
    
                                               ));
    
                        $attachmentId = $entityManager->saveEntity($attachment); 
    
    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

    Comment

    Working...