---
schema_version: "1"
id: 7cb03b1008802d59c8f1bf74fae433d6db149024851ed92103ce671be61adfd5
title: Data Save Inside of a Custom Component (Managed Package)
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/xcloud/264-0-0/os_save_data_inside_custom_component_vlocity.md
canonical_url: https://help.salesforce.com/s/articleView?id=xcloud.os_save_data_inside_custom_component_vlocity.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 010ae2de919fb3d0ee64472be9f26ab16295f61b43ba65e09b9834e827e3d121
description: "For the managed package runtime, when the custom component doesn’t exist in the DOM, store the data in a state. To store data in a state, use the omniSaveState() function. The omniSaveState function accepts three arguments: a data object, a key, and a boolean."
products:
  - Omnistudio
release: "264"
---
# Data Save Inside of a Custom Component (Managed Package)

For the managed package runtime, when the custom component doesn’t exist in the DOM, store the data in a state. To store data in a state, use the `omniSaveState()` function. The `omniSaveState` function accepts three arguments: a data object, a key, and a boolean.

![Managed Package app icon](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio_for_managed_packages-264-0-0-production-enus/aa2554ec-624a-4ee6-8da4-6435670e6e62/resources-global/_corporate/images/managedpackageicon.png) This information is for Omnistudio for Managed Packages. For Omnistudio on standard runtime, see [Omnistudio Help](https://help.salesforce.com/s/articleView?id=xcloud.os_omnistudio_standard.htm&language=en_US).

Method: `omniSaveState(input,key,usePubSub=false)`:

Arguments:

- `input`: The data to be saved.
    
    ```
    let mySaveState = {"my":"data"};
    this.omniSaveState(mySaveState);
    ```
- `key`: (Optional) A string value that the object parameter maps to as a key-value pair. If a key isn’t sent as a parameter, the key defaults to the name of the component.
    
    ```
    let mySaveState = {"my":"data"};
    let key = 'customLwcKey';
    this.omniSaveState(mySaveState, key);
    ```
- `usePubSub`: (Optional) Set the boolean to true to store data for use in a pubsub pattern. When left empty or set to false, the data is usable by events. For more information on events, see [LWC Events](https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.events). When `omniSaveState` is in a `disconnectedCallback`, `usePubSub` must be set to `true` to pass the event in the pubsub instead of event bubbling.

Beginning with Vlocity Insurance and Health Winter '20 , optionally save the state within a disconnected callback. Saving the state within a disconnected callback enables the state of the element to save when users leave the element automatically. In disconnected callbacks, the `usePubSub` argument must be set to `true`. Events in disconnected callbacks can only be passed using pubsub.

Optionally save the state within a disconnected callback. Saving the state within a disconnected callback enables the state of the element to save when users leave the element automatically. In disconnected callbacks, the `usePubSub` argument must be set to `true`. Events in disconnected callbacks can only be passed using pubsub.

![Example](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio_for_managed_packages-264-0-0-production-enus/aa2554ec-624a-4ee6-8da4-6435670e6e62/images/icon_example.png)

Example `omniSaveState` being called in a `disconnectedCallback`:

```
disconnectedCallback() {
  let mySaveState = {"my":"data", "here" : 8};
  let key = 'customLwcKey';
  let usePubSub = true;
  this.omniSaveState(mySaveState, key, usePubSub);
}
```