Announcement

Collapse
No announcement yet.

'Public' access to documents in EspoCRM?

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

  • 'Public' access to documents in EspoCRM?

    Is it possible to expose documents in EspoCRM through a public link (similar to how you can do that in Dropbox)?

    Background:
    I want to send a mailing to 100+ contacts. Most contacts are not portal users. In the mail, I have included a link to a document which I want to share with them. This document resides in the 'documents' section in EspoCRM. When the contacts click the link, they are asked for their EspoCRM credentials, which they do not have. How can I specify that a document is a 'public' document?

    Many thanks,
    Ronald

  • #2
    You could create publicly available entryPoint which will allow access to documents which have specific param.

    Comment


    • #3
      Hi, here is how I do that:

      emillod , I hope you don`t mind, that I link to your extension Public Attachment

      First I install the extension by devcrm.it: https://github.com/dubas-pro/ext-public-attachment

      For the link I do as follows:

      1. I created a custom formula to read the current URL from a record (the record, where in my case I have an image, that I want to be downloadable). I did not test that with documents, but either it should work or you link the document into another entity.

      2. I create one field for the URL
      3. I create one field with the entry point, that the extension provides (?entryPoint=DubasPublicAttachment&id=). In the field configuration I set this as default, so it will appear in any new record
      4. I create another field with the ID of (in my case) the image, which I populate by formula
      5. I create an URL field for the image address, by concatenating the URL, entry point and ID, reading thes values from the former created field

      I now have an URL, that I can send by mail and using the link, opens the image for where I sent the mail.

      The custom formula to read the current URL (according to https://docs.espocrm.com/development...-in-formula/):

      Code:
      <?php
      
      namespace Espo\Custom\Core\Formula\Functions\Base\StringGrou p;
      
      use Espo\Core\Utils\{
      Config,
      Config\ConfigFileManager
      };
      
      class GetSiteUrl extends \Espo\Core\Formula\Functions\Base {
      
      public function process(\StdClass $args = null) {
      $fileManager = new ConfigFileManager();
      $config = new Config($fileManager);
      return $config->getSiteUrl();
      }
      
      }
      and

      ​​​​​​​
      Code:
      {
      "functionList": [
      "__APPEND__",
      {
      "name": "string\\getSiteUrl",
      "insertText": "string\\getSiteUrl()"
      }
      ],
      "functionClassNameMap": {
      "string\\getSiteUrl": "Espo\\Custom\\Core\\Formula\\Functions\\Base\\Str ingGroup\\GetSiteUrl"
      }
      }
      The respective formula:

      Code:
      currentURL=string\getSiteUrl();

      Comment


      • #4
        More right way:

        PHP Code:
        <?php

        namespace Espo\Custom\Core\Formula\Functions\Base\StringGroup;

        use 
        Espo\Core\Formula\Functions\BaseFunction;
        use 
        Espo\Core\Formula\ArgumentList;

        use 
        Espo\Core\Di;

        class 
        GetSiteUrl extends BaseFunction implements Di\ConfigAware
        {
            use 
        Di\ConfigSetter;

            public function 
        process(ArgumentList $args): string
            
        {
                 return 
        $this->config->get('siteUrl');
            }
        }

        Comment


        • #5
          Thanks for this, folks, but I am not quite there yet.

          I installed the extension without problems. For now, I do not need to retrieve the URL automatically, so I am focussing on getting the correct URL first. Here's my basic attempt:

          - I have a (PDF) document with ID '623c31ef1872d1a5d'
          - I use the URL https://[myespocrmsite]/?entryPoint=...c31ef1872d1a5d

          When I try this URL, I get an error:

          403 Forbidden
          EntryPoint Attachment: Not allowed type application/pdf.

          Shouldn't this URL then give public access to the document? What am I missing?

          Many thanks, Ronald

          Comment


          • #6
            You go to the Entity Manager -> entity Documents
            There you look for the field, where you save your documents. In thenconfiguration for that field, there is a field for allowed file-types, click into this field and choose the file-extensions you want to allow, among which you should choose pdf of course.
            Then it should work.

            Your URL structure should look like:

            PHP Code:
            https://[myespocrmsite]/?entryPoint=DubasPublicAttachment&id=623c31ef1872d1a5d 
            Last edited by shalmaxb; 03-29-2022, 09:54 PM.

            Comment

            Working...
            X