Skip to content
Lightning Web Components, Omniscript

How to pass Data from Omniscript to Custom LWC?

July 8, 2025

How to pass Data from Omniscript to Custom LWC? In this article, we will walk through how to create a custom Lightning Web Component (LWC) that receives data from an OmniScript in two different ways: 

  • Using @api property (Directly Passed Property). 
  • Using this.omniJsonData (OmniScript JSON Data Object). 

How to pass Data from Omniscript to Custom LWC?

We want our LWC (childLWC) to display a color name and its value, which are set in the OmniScript using two different methods: 

  1. Directly via a property (@api) from a Set Values JSON (currentColor). 
  1. Indirectly from the OmniScript JSON object (this.omniJsonData.data). 

LWC Setup: childLWC

1. HTML File (childLWC.html): 

2. JavaScript File (childLWC.js): 

OmniscriptBaseMixin(LightningElement): This is a special mixin provided by Vlocity/Industries (Salesforce OmniStudio). 

  • It gives your LWC direct access to OmniScript data using this.omniJsonData and other OmniScript methods.
  • This is critical for accessing and interacting with the data directly in OmniScript.

@track makes variables reactive, automatically updating the UI when their values change.

@api exposes a property to the parent component, allowing direct data passing to the LWC.

3. Configuration File (childLWC.xml):

Setting <isExposed>true</isExposed> means that the LWC can be used outside the Salesforce Experience Builder or directly in an OmniScript. 
Also Read: How to Enable Debug Mode for Lightning Web Components in Salesforce?

OmniScript Setup

Two Set Values Elements:

  • setData (First Set Value)
  • setDataOmni (Second Set Value)

Custom LWC Element (Adding the LWC):

From the build panel in your omniscript, drag and drop Custom Lightning Web Component into your OS Step and in its properties panel.

Search for our customLWC. 

  • LWC Name: childLWC (API Name of your custom LWC).

    And pass the “CUSTOM LIGHTNING WEB COMPONENT PROPERTIES” as 

  • Property Name: color.
  • Value: %currentColor% (This passes the JSON value directly to the LWC). 

How It Works?

  • The OmniScript passes two sets of data:
  • colorName (JSON as a String) to the LWC using the @api property.
  • In the LWC:
  • The @api property (colorName) receives the JSON directly from the OmniScript.
  • The JSON strings are parsed using JSON.parse() to convert them into JavaScript objects.
  • These parsed objects are then displayed in the LWC HTML.

Why Use Two Methods?

  • @api Property: Direct and fast. Ideal for small data directly passed to the LWC.
  • this.omniJsonData: Flexible for accessing any data within the OmniScript, especially useful when you have multiple data values and want to dynamically access them.

Keep Reading

Related Articles and Resources

Messaging Element in Omniscript
November 17, 2024

Messaging Element in Omniscript

Configure the Messaging element to display comments,...

How to Pass List/Obj to Integration Procedure from FlexCard?
November 10, 2024

How to Pass List/Obj to Integration Procedure from FlexCard?

Passing Input to a Integration Procedure, the syntax is...

Best Practices To Follow for Omnistudio Omniscript
June 11, 2025

Best Practices To Follow for Omnistudio Omniscript

Are you looking for the Best Practices To Follow for...

A Beginner’s Guide to OmniStudio: Streamlining Your Salesforce Experience (FlexCards)
October 27, 2024

A Beginner’s Guide to OmniStudio: Streamlining Your Salesforce Experience (FlexCards)

What is Omnistudio OmniStudio is a powerful set of...

Salesforce Revenue Cloud Mapping Fields from Quote to Quote Line
September 27, 2025

Salesforce Revenue Cloud Mapping Fields from Quote to Quote Line

Salesforce Revenue Cloud has proven to be a critical...

Migrating From CPQ Classic to Revenue Cloud Advanced
January 8, 2026

Migrating From CPQ Classic to Revenue Cloud Advanced

The conversation isn’t about whether to migrate from...