Saturday, 22 April 2023

D365 CE - JS check the client is offline or online

Greetings, Dynamics Techies! As the world of Dynamics evolves, we are faced with the challenge of developing JavaScript that can seamlessly transition between online and offline modes. With the introduction of the offline profile, this challenge has become more pressing than ever before. 

 To help navigate these waters, I am excited to announce a new series of blog posts where I will be sharing my learnings and insights on developing JavaScript for both online and offline modes in Dynamics. Whether you're a seasoned developer or just starting out, these posts will provide valuable tips and tricks for ensuring your JavaScript is compatible with both modes, allowing for a smoother, more efficient user experience. 



 So, join me as we explore the world of Dynamics JavaScript development and discover how we can make the most of this exciting technology. Together, we can tackle the challenges of offline and online modes and unlock the full potential of Dynamics.


var clientContext = Xrm.Utility.getGlobalContext().client;
if (clientContext.getClientState() === "Offline") {
    // User is offline
} else {
    // User is online
}

Happy Learning!

Reference:

https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-utility/getglobalcontext/client#syntax-1

No comments:

Post a Comment