Announcement

Collapse
No announcement yet.

Adding a JS script to EspoCRM

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

  • Adding a JS script to EspoCRM

    Hello,

    I would like to add a guided tour script like Shepherd.js or GuideChimp. Both work with a js and a css and you have to create a js with the tour steps you want.

    I followed the documentation, adding js and css in client/custom/, declaring the paths in custom/Espo/Custom/Resources/metadata/app/client.json.
    On reloading, the css and the js I made for the steps tour are loaded but the js file from the script (either shepherd.js or guidechimp.min.js) is blocked by the Content Security Policy.

    I found that I can whitelist a script in config but the exemple gives a url while I need to whitelist a JS script ('client/custom/js/guidechimp.min.js' doesn't do the trick).
    How should I declare it?

    Any other form to implement this type of script?

    Thank you

  • #2
    Hi,

    What exactly the error do you get in the console? You should not white list scripts that are located on the same server.

    Comment


    • #3
      Hello Yuri,

      Thank you for your interest in my case.

      The console response is:
      Code:
      Content Security Policy: The page’s settings blocked the loading of a resource at inline (“script-src”). moz-extension:1:294
      Content Security Policy: The page’s settings blocked the loading of a resource at inline (“script-src”). moz-extension:58:25
      Content Security Policy: The page’s settings blocked the loading of a resource at inline (“script-src”).​ moz-extension:75:38
      My client.js:
      Code:
      {
      "cssList": [
      "__APPEND__",
      "client/custom/css/guidechimp.min.css"
      ],
      "scriptList": [
      "__APPEND__",
      "client/custom/guidechimp.js"
      
      ],
      "scriptList": [
      "__APPEND__",
      "client/custom/js/tour.js"
      ]
      }​
      if I put
      Code:
      "linkList": [
      "__APPEND__",
      {
      "href": "client/custom/guidechimp.js",
      "as": "javascript",
      "type": "text/javascript",
      "rel": "preload",
      "noTimestamp": true,
      "crossorigin": true
      }
      ],
      I get a blank page on reloading Espo.


      I also tried in config-internal.php with no success.
      Code:
      'clientCspScriptSourceList' => [
      0 => 'https://cdn.jsdelivr.net/npm/guidechimp@4/dist/guidechimp.js'​
      Should I do it another way?

      Comment


      • #4
        Maybe try in Chrome and see whether there are more details printed in the console. It should show recommendation what exactly should be added the white list.

        Comment


        • #5
          The console error message:

          Code:
          Uncaught ReferenceError: GuideChimp is not defined
              at tour.js?r=1706804944:88:18​
          because the main javascript file ("guidechimp.js", either with the cdn instruction or appending the file locally) isn't loaded:

          Code:
           <script type="text/javascript" src="client/lib/espo.js?r=1706804944" data-base-path=""></script>
                  <script type="text/javascript" src="client/lib/espo-main.js?r=1706804944" data-base-path=""></script>
                  <script type="text/javascript" src="client/custom/js/tour.js?r=1706804944" data-base-path=""></script>
                  <link rel="stylesheet" href="client/css/espo/espo.css?r=1706804944" id='main-stylesheet'>
                  <link rel="stylesheet" href="client/custom/css/guidechimp.min.css?r=1706804944">
                  <link rel="preload" href="client/fonts/open-sans/open​...
          The console doesn't say more about this error.

          Comment

          Working...
          X