Skip to main content

Notifications

Community site session details

Community site session details

Session Id : pGJ6CoqDIxmFEfm+O8+YdR
Power Apps - Building Power Apps
Answered

JavaScript - Online or offline

Like (0) ShareShare
ReportReport
Posted on 10 Oct 2022 05:58:07 by 46

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

Categories:
  • Verified answer
    Ryan Brumpton Profile Picture
    11 on 26 Jan 2024 at 14:52:39
    Re: JavaScript - Online or offline

    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

  • msabau Profile Picture
    270 on 11 Oct 2022 at 07:09:56
    Re: JavaScript - Online or offline

    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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,660 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard
Loading started