<?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 Pass data to a visual in an embedded report in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Pass-data-to-a-visual-in-an-embedded-report/m-p/4042411#M54184</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I have a question regarding the possibility to send data to a visual inside an embedded report.&lt;/P&gt;&lt;P&gt;This can somehow be related to my other &lt;A href="https://community.fabric.microsoft.com/t5/Developer/LocalStorage-v2-and-embedded-reports/m-p/4028594#M53986" target="_self"&gt;post&lt;/A&gt;, since for what I see and I have tested, the localstorage API is not working in embedded mode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the powerbi-client JS library in the HTML code used for embedding the report, but without success.&lt;/P&gt;&lt;P&gt;This is the demo code I have used for the tests:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Embed Power BI Custom Visual&amp;lt;/title&amp;gt;
    &amp;lt;script src="https://cdnjs.cloudflare.com/ajax/libs/powerbi-client/2.23.1/powerbi.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;div&amp;gt;
        &amp;lt;input type="text" id="customParam" placeholder="Enter Custom Param"&amp;gt;
        &amp;lt;button onclick="updateReport()"&amp;gt;Update Report&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
    
    &amp;lt;div id="reportContainer" style="height:600px;"&amp;gt;&amp;lt;/div&amp;gt;

    &amp;lt;script&amp;gt;
        var models = window['powerbi-client'].models;
        var reportContainer = document.getElementById('reportContainer');

        var embedConfig = {
            type: 'report',
            id: 'YOUR_REPORT_ID',  // Replace with your report ID
            embedUrl: 'YOUR_EMBED_URL',  // Replace with your embed URL
            accessToken: 'YOUR_ACCESS_TOKEN',
            permissions: models.Permissions.All,
            settings: {
                filterPaneEnabled: false,
                navContentPaneEnabled: true
            }
        };

        var report = powerbi.embed(reportContainer, embedConfig);
		
		function updateReport() {
            var customParam = document.getElementById("customParam").value;
			
			console.log("update report!!!");

            //report.on("loaded", function() {
				console.log("loaded!");
			
                report.getPages()
                    .then(function(pages) {
                        var activePage = pages[0]; // Assuming your visual is on the first page
                        activePage.getVisuals()
                            .then(function(visuals) {
								console.log("visuals", visuals);
								
                                // Find custom visual by name or by custom identifier
                                var customVisual = visuals.find(visual =&amp;gt; visual.type === 'myVisualF2AE6C1440294E95BE39535129C02025'); // Replace with your visual name
                                
								console.log("custom", customVisual);
								console.log("report", report);
								
								if (customVisual) {
									customVisual.setProperties({
										objects: {
											settings: {
												customString: {
												value: customParam
											}
										}
									}
								});
								}
                            });
                    });
            //});
        }
    &amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 15 Jul 2024 11:04:03 GMT</pubDate>
    <dc:creator>pietrodig</dc:creator>
    <dc:date>2024-07-15T11:04:03Z</dc:date>
    <item>
      <title>Pass data to a visual in an embedded report</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Pass-data-to-a-visual-in-an-embedded-report/m-p/4042411#M54184</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I have a question regarding the possibility to send data to a visual inside an embedded report.&lt;/P&gt;&lt;P&gt;This can somehow be related to my other &lt;A href="https://community.fabric.microsoft.com/t5/Developer/LocalStorage-v2-and-embedded-reports/m-p/4028594#M53986" target="_self"&gt;post&lt;/A&gt;, since for what I see and I have tested, the localstorage API is not working in embedded mode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the powerbi-client JS library in the HTML code used for embedding the report, but without success.&lt;/P&gt;&lt;P&gt;This is the demo code I have used for the tests:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Embed Power BI Custom Visual&amp;lt;/title&amp;gt;
    &amp;lt;script src="https://cdnjs.cloudflare.com/ajax/libs/powerbi-client/2.23.1/powerbi.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;div&amp;gt;
        &amp;lt;input type="text" id="customParam" placeholder="Enter Custom Param"&amp;gt;
        &amp;lt;button onclick="updateReport()"&amp;gt;Update Report&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
    
    &amp;lt;div id="reportContainer" style="height:600px;"&amp;gt;&amp;lt;/div&amp;gt;

    &amp;lt;script&amp;gt;
        var models = window['powerbi-client'].models;
        var reportContainer = document.getElementById('reportContainer');

        var embedConfig = {
            type: 'report',
            id: 'YOUR_REPORT_ID',  // Replace with your report ID
            embedUrl: 'YOUR_EMBED_URL',  // Replace with your embed URL
            accessToken: 'YOUR_ACCESS_TOKEN',
            permissions: models.Permissions.All,
            settings: {
                filterPaneEnabled: false,
                navContentPaneEnabled: true
            }
        };

        var report = powerbi.embed(reportContainer, embedConfig);
		
		function updateReport() {
            var customParam = document.getElementById("customParam").value;
			
			console.log("update report!!!");

            //report.on("loaded", function() {
				console.log("loaded!");
			
                report.getPages()
                    .then(function(pages) {
                        var activePage = pages[0]; // Assuming your visual is on the first page
                        activePage.getVisuals()
                            .then(function(visuals) {
								console.log("visuals", visuals);
								
                                // Find custom visual by name or by custom identifier
                                var customVisual = visuals.find(visual =&amp;gt; visual.type === 'myVisualF2AE6C1440294E95BE39535129C02025'); // Replace with your visual name
                                
								console.log("custom", customVisual);
								console.log("report", report);
								
								if (customVisual) {
									customVisual.setProperties({
										objects: {
											settings: {
												customString: {
												value: customParam
											}
										}
									}
								});
								}
                            });
                    });
            //});
        }
    &amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2024 11:04:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Pass-data-to-a-visual-in-an-embedded-report/m-p/4042411#M54184</guid>
      <dc:creator>pietrodig</dc:creator>
      <dc:date>2024-07-15T11:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: Pass data to a visual in an embedded report</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Pass-data-to-a-visual-in-an-embedded-report/m-p/4043316#M54190</link>
      <description>&lt;P&gt;Hi&amp;nbsp; &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/620487"&gt;@pietrodig&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to the description of your document, I can understand that the localstorage API can be applied to some SaaS platforms, but it is not certain that the localstorage API can be applied to all SaaS platforms, you can try to do the embedded operation on the common visual to check whether it is successful or not, and if only your custom visual cannot run successfully, and you confirm that the steps of passing parameters have been fully configured, you can also go to the developer forum of the corresponding custom visual to raise a related question if convenient. If only your custom visual fails to run successfully, and you confirm that the steps for passing parameters have been fully configured, you can also go to the developer's forum of the corresponding custom visual to ask a related question.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/bd-p/CustomVisualsDevelopmentDiscussion" target="_blank"&gt;Custom Visuals Development Discussion - Microsoft Fabric Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/58424756/powerbi-custom-visuals-how-to-programmatically-switch-between-report-pages-in" target="_blank"&gt;javascript - PowerBI custom visuals - How to programmatically switch between report pages in a custom visual using PowerBI API? - Stack Overflow&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Liu Yang&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;EM&gt;Accept it as the solution&lt;/EM&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2024 02:19:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Pass-data-to-a-visual-in-an-embedded-report/m-p/4043316#M54190</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-07-16T02:19:39Z</dc:date>
    </item>
  </channel>
</rss>

