Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
tarockx
Frequent Visitor

Using the LocalStorage service inside a Dialog Box

Hello everyone

 

I'm developing a custom visual that makes use of Dialog Boxes, as documented here.

The visual also uses the local storage API to read and write data to the local storage.

 

Now, while these two features work well on their own, there is a problem when trying to use them together.

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.

In particular, the DialogBox's options do not give access to the IVisualLocalStorageV2Service. So, unlike with the main Visual's class, we cannot obtain the storage service in a DialogBox like this:

tarockx_0-1711132616922.png

as you can see, we get an error because that property doesn't exist.

It also cannot be passed through via the "initialState" object, since it seems IVisualLocalStorageV2Service is not serializable.

 

How can we work around this? Is ti possible?

1 ACCEPTED SOLUTION
dm-p
Super User
Super User

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.

 

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.

 

If this is not a suitable approach, you will need to request that MS add the feature to the dialog box host (via [email protected] or the Power BI Visuals API repo). 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.

 

Regards,

 

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




View solution in original post

2 REPLIES 2
dm-p
Super User
Super User

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.

 

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.

 

If this is not a suitable approach, you will need to request that MS add the feature to the dialog box host (via [email protected] or the Power BI Visuals API repo). 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.

 

Regards,

 

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




lbendlin
Super User
Super User

What kind of UX are you trying to achieve combining these features?

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors