Browser Storage Component

The Browser Storage component lets you add, edit, delete, and retrieve data in an end-user's browser. The component stores data using the IndexedDB API. IndexedDB is a large storage service for encrypting and storing data in a browser. This API lets you store large amounts of structured, indexed information locally, letting you filter and search this information.

Data stored in a browser expires after 30 days. The expiration time resets when the end-user accesses the data.

Only end-users can access the encrypted data stored on their browser.

You'll find the Browser Storage component in the Data & Event Processing group to the left of the Module Builder.

To learn more about general component settings, view our General Component Settings article.

A static image displaying the Browser Storage component's configuration window Data settings.

Setting Description

Interaction Type

The Browser Storage component has the following options:

  • Write: This interaction lets you create and update data in the IndexedDB object. Use the component's Filters table when creating or updating information. If there's information you want to update, enter the Property ID of that information in the Filters table. The component filters on that Property ID and merges or overwrites the information. If there's no match to the Property ID, or the field is blank, the component creates a new submission.

  • Read: This interaction views filtered data. It also searches for individual offline submissions. To find offline data, use the suffix: /display/:formId/local/:namespace/:submissionId, like you do when searching for a specific submission ID. The Namespace is the unique identifier you create for your stored information.

  • Delete: This interaction deletes locally-stored data from the IndexedDB object.

To learn more about the IndexedDB API, view the following documentation: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API

Namespace

A Namespace is required. This is a unique label applied to the information you store in the IndexedDB object. The Read, Write, and Delete interactions happen only to the data entered in the Namespace.

It's best practice to use your module's unique module ID in the Browser Storage component's Namespace. For example, inspections5ffddf6ae336b802494437c8, where 5ffddf6ae336b802494437c8 is the module ID of the front-end source module. The Namespace is where the source module stores its data on the browser.Only use Property IDs or grid syntax in Input and Output tables, unless referring to nested data in a Plug-In component.
The Namespace field uses autocomplete to suggest Namespaces used elsewhere in the environment.

A static image displaying the Browser Storage's Data Filter settings.

Setting Description

Filters

The Browser Storage component's Filters table helps you find information stored in the browser's IndexedDB object store.

Property ID

This is the Property ID of the stored information. Mapping to this Property ID performs the Write, Read, and Delete operations to that data.

The Property ID entered must match the Property ID used in the input component. Remember, use camel case (stylized as camelCase) without spaces or punctuation.

Set Filter To

This drop-down lets you select how you want to compare the Filter’s Property ID to its Mapping. Your options are: =, <, or >.

Mapping

Mapping describes where in the stored data you're filtering. This mapping information tells the component what data send or call when triggered.

Required

If (checked), the end-user must enter a value in the field of this input component before the logic component executes.

By default, this setting is ☐ (unchecked).

Exclude

If (checked), the filter operation does not run when you trigger the Browser Storage component.

By default, this setting is ☐ (unchecked).

Optional

If (checked), or if the field has no value, the operation does not run when you trigger the Browser Storage component. By default, all inputs in the request body progress, even if the field is empty (null).

By default, this setting is ☐ (unchecked).

Replace

This setting is only available when the Interaction Type is set to Write. If this setting is  (ON), the entire data object is replaced when you make changes. If this setting is (OFF), the new data merges into the data object.

By default, this setting is (OFF).

Input settings are only available for the Write operation.

A static image displaying the Browser Storage component's Data Inputs table.

Setting Description

Property ID

This Property ID refers to your triggering component. Use this field to enter values that you send to the browser’s IndexedDB object store.

Mapping

API documentation includes mapping information. This mapping information tells the Browser Storage component which information to send or call from the browser's IndexedDB object store.

Discover more about the Unqork API documentation here: https://developers.unqork.io/.

Required

If (checked), the end-user must enter a value in the field of this input component before the logic component executes.

By default, this setting is ☐ (unchecked).

Exclude

If (checked), the component does not pass the field as part of the API call's request body. The component still watches for changes to the value.

By default, this setting is ☐ (unchecked).

Optional

If (checked), and the field has no value, the operation does not run when triggered. By default, all inputs in the request body work, even if the field is empty (null).

By default, this setting is ☐ (unchecked).

A static image displaying the Browser Storage component's Data Outputs table.

Setting Description

Property ID

This Property ID is where you want the component to send the data retrieved from your browser. For your logic component to recognize an output, you must enter the destination component's Property IDs.

The Property ID you enter must match the Property ID used in the output component. Remember, use camel case (stylized as camelCase) without spaces or punctuation.

Mapping

Map Property IDs according to API specifications. Mapping tells your component what to retrieve from the browser. For example, enter 0.data.storedExample to retrieve the first stored submission. The [0] represents your first saved record, [1] is the second, and so on.

First, you'll configure a survey application for use offline. This survey has fields for a surveyor's name, the date surveyed, and other various criteria. This front-end module lets you input values that a Browser Storage component writes to the browser cache.

For a completed example of the survey application, view the training environment module here: https://training.unqork.io/#/form/5ffddf6ae336b802494437c8/edit.

This example assumes you have a module saved and with a title.

Configure the Initializer Component

This Initializer component triggers the Browser Storage component to retrieve submission data from the browser.

1. In the Module Builder, drag and drop an  Initializer component onto the canvas.
2. In the Property ID field, enter initGetOfflineSubmissions.
3. In the Canvas Label Text field, enter initGetOfflineSubmissions.
4. From the Trigger Type drop-down, select New Submission.
5. In the Outputs table, enter the following:
  Property ID Type Value

1

readOfflineSubmissions

trigger

GO

A static image displaying the Initializer component's Acction settings. The Trigger Type is set to New Submission and the  Outputs Table includes a row with the readOfflineSubmissions property ID.

6. Click Save Component.

Configure the Browser Storage Component

Next, you'll configure a Browser Storage component to retrieve the data from your browser’s storage, using the Inline image displaying a selected radio button. Read interaction to view offline submissions.

1. Drag and drop a Browser Storage component onto your canvas, placing it below your initGetOfflineSubmissions  Initializer component.
2. In the Property ID field, enter readOfflineSubmissions.
3. In the Canvas Label Text field, enter readOfflineSubmissions.
4. Set the Interaction Type to Inline image displaying a selected radio button. Read.
5. In the Namespace field, enter inspectionsModuleId. Where ModuleId is the ID value of your module. For example inspections5ffddf6ae336b802494437c8.

For this example, the Namespace refers to the Browser Storage data created in the following training module: https://training.unqork.io/#/form/5ffddf6ae336b802494437c8/edit.

6. In the Outputs table, enter the following:
  Property ID Mapping

1

hiddenOfflineSubmissions

 

This Property ID matches the Hidden component you'll set up next.

A static image displaying the Browser Storage component's Data Settings. The Interaction type is set to Read, the Namespace is filled, and the Outputs table contains the hiddenOfflineSubmissions Property ID.

7. Click Save Component.

Configure the Hidden Component

Add a Hidden component to store offline submissions made by the end-user.

1. Drag and drop a Hidden component onto the canvas, placing it below the readOfflineSubmissions Browser Storage component.
2. In the Property ID and Label Text fields, enter hiddenOfflineSubmissions.
3. Click Save Component.
4. Save your module.

Preview your module in Express View, and open the DevTools Console. Open the object to see the submission data created from the front-end source module.

The IndexedDB stores data in an array of objects. Each object contains the submission data collected in the front-end module.

A static image displaying the Data Structure of a Browser Storage object.

Resources