Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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?
Solved! Go to Solution.
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.
@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.
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.
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.
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
Proud to be a Super User!
On how to ask a technical question, if you really want an answer (courtesy of SQLBI)
User | Count |
---|---|
5 | |
5 | |
3 | |
2 | |
2 |
User | Count |
---|---|
10 | |
7 | |
5 | |
4 | |
4 |