You are here:
Clear a Saved State from a Previous Step (Managed Package)
For the managed package runtime, beginning with Vlocity Insurance and Health Winter '20 , when a Custom LWC's saved state relies on data from a previous step, you can conditionally clear the saved state of the Custom LWC whenever a user navigates to a previous step. After configuration, the Step element passes a boolean flag to the custom LWC. The code in your Custom LWC must use the boolean to determine whether to instantiate a new saved state or continue using the existing saved state.
This information is for Omnistudio for Managed Packages. For Omnistudio on standard runtime, see Omnistudio Help.
To configure the clear saved state functionality:
- In Omniscript, determine the Step that clears the Custom LWCs saved state.
- In the Step's properties, click Edit as JSON.
-
Enter the property
"omniClearSaveState": [ ]. -
In the omniClearSaveState property, enter the name of one or more custom LWC elements
"omniClearSaveState": [ "CustomLWC1"]. The Step sends data to the Custom LWC enabling the Custom LWC to determine if the Step rendered. -
In your Custom LWC's code, retrieve the current state.
const state = this.omniGetSaveState() -
In your Custom LWC's code, set a variable equal to
this.omniGetSaveState(this.omniJsonDef.name + '-$Vlocity.cleared'. The function evaluates whether the previous Step containing the omniClearSaveState property rendered and returns a boolean.let stateCleared = this.omniGetSaveState(this.omniJsonDef.name + '-$Vlocity.cleared'); - Modify your code by using the boolean value to determine whether to keep the current saved state or instantiate a new saved state.

