
When developing in Creatio you might need to persist some information or data between pages, or share something between different parts of the application. There are many ways to do this sort of thing in Javascript, but Creatio does provide a simple way to persist data in the client-side session so you can share data between requests or pages. This is done using the StorageUtilities module.
To use the StorageUtilities module, you need to add it as an import into your code. For example, if you’re using this in the Contact page, you’ll add it to the top line like this:
define("ContactPageV2", ["StorageUtilities"], function(StorageUtilities) { return { entitySchemaName: "Contact", // ... all the rest of the stuff }; });
Now, you’ll have the StorageUtilities object available to use.
To Set a Value To Save in Client-Side Storage
To save a value in the client-side storage, you can use the following. You’ll give the item a unique name for it’s key, you’ll use that key to retrieve the value:
StorageUtilities.setItem("I am saving this string", "MyItemKey");
Note the parameter order: the first parameter is the data you are saving and the second parameter is the key (or name) for what you’re saving (which feels backwards to me)
To Get a Value from Client-Side Storage
To get a value from the client-side storage, you’ll use the key you specified when you added the item to the storage:
if (!Ext.isEmpty(StorageUtilities.getItem("MyItemKey")) { var myValue = StorageUtilities.getItem("MyItemKey"); }
Warning
Be aware, this value is persisted in the Terrasoft object loaded in the browser. It is not shared between browser tabs and will be lost if the user refreshes the page or logs out and back in again. This is not saved to the database. If you need the value to persist between sessions, it’s better to use a system setting with a value set for each user.
Subscribe To Our Newsletter
Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!
You have Successfully Subscribed!