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.
This information is for Omnistudio for Managed Packages. For Omnistudio on standard runtime, see Omnistudio Help.
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. WhenomniSaveStateis in adisconnectedCallback,usePubSubmust be set totrueto 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.
omniSaveState being called in a disconnectedCallback:
disconnectedCallback() {
let mySaveState = {"my":"data", "here" : 8};
let key = 'customLwcKey';
let usePubSub = true;
this.omniSaveState(mySaveState, key, usePubSub);
}