<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Custom visual external Javascript in PowerBi Desktop Issue in Custom Visuals Development Discussion</title>
    <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Custom-visual-external-Javascript-in-PowerBi-Desktop-Issue/m-p/1867728#M3706</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;We have custom visual component taht needs to use external javascript loaded using the script tag. The second library can't be embedded via node modules.&lt;BR /&gt;Here is an extract from our source code :&lt;BR /&gt;private scriptsUrl: string[] = [&lt;BR /&gt;"//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js",&lt;BR /&gt;"&lt;A href="https://api.bimsync.com/1.0/js/viewer.js" target="_blank" rel="nofollow noopener noreferrer"&gt;https://api.bimsync.com/1.0/js/viewer.js&lt;/A&gt;"];&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;private loadNext = (resolve, reject) =&amp;gt;{&lt;BR /&gt;const scriptsUrlElement = this.scriptsUrl[this.loadCount];&lt;BR /&gt;let htmlScriptElement = document.createElement('script');&lt;BR /&gt;htmlScriptElement.src=scriptsUrlElement;&lt;BR /&gt;htmlScriptElement.crossOrigin = "anonymous";&lt;BR /&gt;document.body.appendChild(htmlScriptElement);&lt;/P&gt;&lt;P&gt;htmlScriptElement.onload = () =&amp;gt; {&lt;BR /&gt;console.info("Viewer scripts loaded");&lt;BR /&gt;this.loadCount++;&lt;BR /&gt;if (this.loadCount &amp;gt;= this.scriptsUrl.length) {&lt;BR /&gt;resolve();&lt;BR /&gt;}else{&lt;BR /&gt;this.loadNext(resolve, reject);&lt;BR /&gt;}&lt;BR /&gt;};&lt;BR /&gt;&lt;BR /&gt;htmlScriptElement.onerror = (message, url, line, column, error) =&amp;gt; {&lt;BR /&gt;console.info("Viewer scripts error:" + error);&lt;BR /&gt;reject({message,url,line,column,error});&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;On web (PowerBi service) it works perfectly but on powerbi desktop we only have an object error (in the onerror) :&lt;BR /&gt;{&lt;BR /&gt;trusted:true&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Is there a way to debug this on powerBI desktop or anything we should do ?&lt;/P&gt;</description>
    <pubDate>Thu, 27 May 2021 13:33:47 GMT</pubDate>
    <dc:creator>etiskapp</dc:creator>
    <dc:date>2021-05-27T13:33:47Z</dc:date>
    <item>
      <title>Custom visual external Javascript in PowerBi Desktop Issue</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Custom-visual-external-Javascript-in-PowerBi-Desktop-Issue/m-p/1867728#M3706</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;We have custom visual component taht needs to use external javascript loaded using the script tag. The second library can't be embedded via node modules.&lt;BR /&gt;Here is an extract from our source code :&lt;BR /&gt;private scriptsUrl: string[] = [&lt;BR /&gt;"//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js",&lt;BR /&gt;"&lt;A href="https://api.bimsync.com/1.0/js/viewer.js" target="_blank" rel="nofollow noopener noreferrer"&gt;https://api.bimsync.com/1.0/js/viewer.js&lt;/A&gt;"];&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;private loadNext = (resolve, reject) =&amp;gt;{&lt;BR /&gt;const scriptsUrlElement = this.scriptsUrl[this.loadCount];&lt;BR /&gt;let htmlScriptElement = document.createElement('script');&lt;BR /&gt;htmlScriptElement.src=scriptsUrlElement;&lt;BR /&gt;htmlScriptElement.crossOrigin = "anonymous";&lt;BR /&gt;document.body.appendChild(htmlScriptElement);&lt;/P&gt;&lt;P&gt;htmlScriptElement.onload = () =&amp;gt; {&lt;BR /&gt;console.info("Viewer scripts loaded");&lt;BR /&gt;this.loadCount++;&lt;BR /&gt;if (this.loadCount &amp;gt;= this.scriptsUrl.length) {&lt;BR /&gt;resolve();&lt;BR /&gt;}else{&lt;BR /&gt;this.loadNext(resolve, reject);&lt;BR /&gt;}&lt;BR /&gt;};&lt;BR /&gt;&lt;BR /&gt;htmlScriptElement.onerror = (message, url, line, column, error) =&amp;gt; {&lt;BR /&gt;console.info("Viewer scripts error:" + error);&lt;BR /&gt;reject({message,url,line,column,error});&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;On web (PowerBi service) it works perfectly but on powerbi desktop we only have an object error (in the onerror) :&lt;BR /&gt;{&lt;BR /&gt;trusted:true&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Is there a way to debug this on powerBI desktop or anything we should do ?&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 13:33:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Custom-visual-external-Javascript-in-PowerBi-Desktop-Issue/m-p/1867728#M3706</guid>
      <dc:creator>etiskapp</dc:creator>
      <dc:date>2021-05-27T13:33:47Z</dc:date>
    </item>
  </channel>
</rss>

