<?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 Using the LocalStorage service inside a Dialog Box in Custom Visuals Development Discussion</title>
    <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Using-the-LocalStorage-service-inside-a-Dialog-Box/m-p/3786873#M9353</link>
    <description>&lt;P&gt;Hello everyone&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm developing a custom visual that makes use of Dialog Boxes, as documented &lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/visuals/create-display-dialog-box" target="_blank"&gt;here&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;The visual also uses the &lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/visuals/local-storage?tabs=v1" target="_blank"&gt;local storage API&lt;/A&gt;&amp;nbsp;to read and write data to the local storage.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, while these two features work well on their own, there is a problem when trying to use them together.&lt;/P&gt;&lt;P&gt;This is becasue, as far as I can tell, there seems to be no way to access the Local Storage API from inside the Dialog Box.&lt;/P&gt;&lt;P&gt;In particular, the DialogBox's options do not give access to the&amp;nbsp;&lt;SPAN&gt;IVisualLocalStorageV2Service. So, unlike with the main Visual's class, we cannot obtain the storage service in a DialogBox like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tarockx_0-1711132616922.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1065325i72AD3F22A03D5E48/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tarockx_0-1711132616922.png" alt="tarockx_0-1711132616922.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;as you can see, we get an error because that property doesn't exist.&lt;/P&gt;&lt;P&gt;It also cannot be passed through via the "initialState" object, since it seems&amp;nbsp;&lt;SPAN&gt;IVisualLocalStorageV2Service is not serializable.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How can we work around this? Is ti possible?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 22 Mar 2024 18:44:45 GMT</pubDate>
    <dc:creator>tarockx</dc:creator>
    <dc:date>2024-03-22T18:44:45Z</dc:date>
    <item>
      <title>Using the LocalStorage service inside a Dialog Box</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Using-the-LocalStorage-service-inside-a-Dialog-Box/m-p/3786873#M9353</link>
      <description>&lt;P&gt;Hello everyone&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm developing a custom visual that makes use of Dialog Boxes, as documented &lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/visuals/create-display-dialog-box" target="_blank"&gt;here&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;The visual also uses the &lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/visuals/local-storage?tabs=v1" target="_blank"&gt;local storage API&lt;/A&gt;&amp;nbsp;to read and write data to the local storage.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, while these two features work well on their own, there is a problem when trying to use them together.&lt;/P&gt;&lt;P&gt;This is becasue, as far as I can tell, there seems to be no way to access the Local Storage API from inside the Dialog Box.&lt;/P&gt;&lt;P&gt;In particular, the DialogBox's options do not give access to the&amp;nbsp;&lt;SPAN&gt;IVisualLocalStorageV2Service. So, unlike with the main Visual's class, we cannot obtain the storage service in a DialogBox like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tarockx_0-1711132616922.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1065325i72AD3F22A03D5E48/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tarockx_0-1711132616922.png" alt="tarockx_0-1711132616922.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;as you can see, we get an error because that property doesn't exist.&lt;/P&gt;&lt;P&gt;It also cannot be passed through via the "initialState" object, since it seems&amp;nbsp;&lt;SPAN&gt;IVisualLocalStorageV2Service is not serializable.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How can we work around this? Is ti possible?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2024 18:44:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Using-the-LocalStorage-service-inside-a-Dialog-Box/m-p/3786873#M9353</guid>
      <dc:creator>tarockx</dc:creator>
      <dc:date>2024-03-22T18:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: Using the LocalStorage service inside a Dialog Box</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Using-the-LocalStorage-service-inside-a-Dialog-Box/m-p/3787107#M9354</link>
      <description>&lt;P&gt;What kind of UX are you trying to achieve combining these features?&lt;/P&gt;</description>
      <pubDate>Sat, 23 Mar 2024 01:23:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Using-the-LocalStorage-service-inside-a-Dialog-Box/m-p/3787107#M9354</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-03-23T01:23:16Z</dc:date>
    </item>
    <item>
      <title>Re: Using the LocalStorage service inside a Dialog Box</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Using-the-LocalStorage-service-inside-a-Dialog-Box/m-p/3788422#M9358</link>
      <description>&lt;P&gt;The dialog box API/host is essentially its own sandboxed iframe, separate from the visual in terms of how Power BI sees it. With this current implementation you can only pass simple objects between the visual and dialog box as a means of state management, as you have observed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your post does not detail your use case, just that you need the feature, so I can't advise what would be a suitable workaround. However, taking a generalized approach, you would need to pass the portion of your local storage you need (hopefully serializable) to the dialog box as part of the options and then update your visual's local storage data with the returned changes when the event is handled in your visual.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this is not a suitable approach, you will need to request that MS add the feature to the dialog box host (via &lt;A href="mailto:pbicvsupport@microsoft.com" target="_blank"&gt;pbicvsupport@microsoft.com&lt;/A&gt; or the &lt;A href="https://github.com/microsoft/powerbi-visuals-api/issues" target="_self"&gt;Power BI Visuals API repo&lt;/A&gt;). To manage your expectations, you will need a very solid justification for any feature requests, so it's best to try and have everything ready to go in terms of having a case for this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 02:27:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Using-the-LocalStorage-service-inside-a-Dialog-Box/m-p/3788422#M9358</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2024-03-25T02:27:31Z</dc:date>
    </item>
  </channel>
</rss>

