We're developing an app that should work both online (Web) and Offline (offline-first tablet). We have an JavaScript event registered for OnSave and in that event we use the XRM WebAPI (https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-webapi)
As described in the link to use the Offline supported WebApi one should use:
var offlineWebApi = Xrm.WebApi.offline;
However in the online scenario one can directly use the Xrm.Api.
How do we determine if we're in the offline or online scenario in JavaScript?
Thanks in advance
Returns information whether the client state is online or offline. A client in offline-first mode always reports it's offline.
clientContext.isOffline()
getGlobalContext.client (Client API reference) in model-driven apps - Power Apps | Microsoft Learn
I had to this once, not on the Power Platform, but on a stand alone app.
I'm not entirely sure about what you mean with offline, because how can you contact an API without connectivity?
But yeah, I made a Get request to something, then based on the code it returns, you can determined if you're online or not
WarrenBelz
146,660
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,004
Most Valuable Professional