Let’s say we have two opened HTML web resources that need to share data between them. Sometimes, we have a hard time trying to do this as XRM Object Model does not have any out of the box method to handle this. However, here is where localStorage comes into play.
// In Web Resource A: // Create a new local storage variable called: Name. // Also, set its value as: "Jhon" localStorage.setItem("Name", "John"); // In Web Resource B: // Retrieve data from local storage variable // created in web resource A var Retrieved_Value = localStorage.getItem("Name"); // *Your logic using the retrieved data* // Remove variable and data from localStorage to // optimize resources localStorage.removeItem("Name");
With these two lines of code, we’re able to share data between two components in MS Dynamics CRM.
Note: localStorage is not limited to MS Dynamics CRM, as it can be used outside as well.
Let me know any questions!