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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
luojiandanbi
New Member

Can store data in LocalStorage on the desktop?

definition localstorage in capabilities.json file:

"privileges": [
    {
        "name": "LocalStorage",
        "essential": true
    }
]

in update(),the code is:

const storage =options.host.storageService;
storage.status().then(status=>{
    this.storageEnv=status.toString();            
})
const key = 'visitorId';
let id:string | undefined;
    id=await storage.get(key);
if(!id)
{
    id=crypto.randomUUID();
    await storage.set(key, id);
}

this is ok in web,but not ok in desktop.

this.storageEnv value is:Allowed in web.

but value is:DisabledByAdmin in desktop.
I want store parameters in localstorage,what can i do?

1 ACCEPTED SOLUTION
Poojara_D12
Super User
Super User

Hi @luojiandanbi 

You're developing a Power BI custom visual that uses the storageService API to store data (like a visitor ID) in local storage, and it works correctly when the visual runs in Power BI Service (the web version). However, in Power BI Desktop, the storage.status() call returns "DisabledByAdmin", which means local storage access is blocked. This happens even though you've correctly declared the LocalStorage privilege as "essential": true in your capabilities.json file. The reason for this is that Power BI Desktop does not support local storage for custom visuals by design, due to security and administrative restrictions—especially in corporate environments where local persistence might be a risk. This behavior cannot be overridden by code or capabilities configuration. As a workaround, if you need to store parameters or state, consider using dataView objects or visual objects (properties saved with the report) for persistent storage across sessions, or use in-memory variables for temporary session-based logic. If you need user-specific storage that persists beyond a report session, you'll likely need to implement an external service or API that your visual can call. In summary, local storage is not supported in Power BI Desktop, and you'll need to adopt an alternative method for storing data based on your use case.

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS

View solution in original post

4 REPLIES 4
luojiandanbi
New Member

@Poojara_D12  @dm-p thanks for reply,I want to store which compute use this custom viusal in desktop, host.persistProperties() API can't achive.this visual not in AppSource,it in the development stage. privileges contains WebAccess,visual code contain eval function,not meeting certification requirements,It seems there is no road.

Poojara_D12
Super User
Super User

Hi @luojiandanbi 

You're developing a Power BI custom visual that uses the storageService API to store data (like a visitor ID) in local storage, and it works correctly when the visual runs in Power BI Service (the web version). However, in Power BI Desktop, the storage.status() call returns "DisabledByAdmin", which means local storage access is blocked. This happens even though you've correctly declared the LocalStorage privilege as "essential": true in your capabilities.json file. The reason for this is that Power BI Desktop does not support local storage for custom visuals by design, due to security and administrative restrictions—especially in corporate environments where local persistence might be a risk. This behavior cannot be overridden by code or capabilities configuration. As a workaround, if you need to store parameters or state, consider using dataView objects or visual objects (properties saved with the report) for persistent storage across sessions, or use in-memory variables for temporary session-based logic. If you need user-specific storage that persists beyond a report session, you'll likely need to implement an external service or API that your visual can call. In summary, local storage is not supported in Power BI Desktop, and you'll need to adopt an alternative method for storing data based on your use case.

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS
v-venuppu
Community Support
Community Support

Hi @luojiandanbi ,

Thank you for reaching out to Microsoft Fabric Community.

Thank you @dm-p for the prompt response.

I wanted to check if you had the opportunity to review the information provided and resolve the issue..? 

Thank you.

dm-p
Super User
Super User

Hi @luojiandanbi,

 

Is your visual in AppSource and certified? This is a limitation of using LocalStorage outside of the developer visual in the Service.

 

If not, then an option is to persist your value to a hidden property using the host.persistProperties() API, and read this in via your update() method like any other property. Note that this does not allow sharing of properties between visual instances, unlike the LocalStorage API, so if you really need this functionality, you may need to consider the publication/certification route.

 

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)




Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.