top of page

    Passing Data Between OmniScript and Custom LWC Component (Two-Way Communication)

    • Writer: VlocityGru
      VlocityGru
    • Jan 6
    • 1 min read

    Introduction


    OmniScript provides powerful UI capabilities in OmniStudio, but there are many scenarios where custom Lightning Web Components (LWC) are required for advanced UI behavior or complex logic.

    A common challenge developers face is:

    • Passing data from OmniScript to a custom LWC

    • Sending updated data back from LWC to OmniScript

    This article explains two-way data communication between OmniScript and a custom LWC using real implementation patterns.


    Step 1: Passing Data from OmniScript to LWC


    OmniScript Configuration -


    1. Add Custom Lightning Web Component element

    2. Provide:

      • LWC Name

      • Property Mapping

    3. Omniscript Screenshot :


    1. Example Omniscript Data JSON

    {
      "accountId": "001XXXXXXXXXXXX",
      "productName": "Internet Plan",
      "quantity": 2
    }

    OmniScript JSON

    LWC Property

    accountId

    account-id

    productName

    product-name

    quantity

    quantity


    Step 2: Receiving Data in LWC


    LWC JavaScript

    import { LightningElement, api } from 'lwc';
    
    export default class OmniCustomComponent extends LightningElement {
        @api accountId;
        @api productName;
        @api quantity;
    }
    
    • @api allows OmniScript to pass data.

    • Property names must match mapping.


    Step 3: Updating Data Inside LWC


    Example input handler:



    Step 4: Sending Data Back from LWC to OmniScript


    This is the most important step.

    Use omniscriptBaseMixin

    Example -




    omniApplyCallResp() updates OmniScript JSON

    ✅ Data becomes available to next steps



    Step 5: Using Updated Data in OmniScript


    After omniApplyCallResp():

    • Data is merged into OmniScript data JSON

    • Available for:

      • Next steps

      • DataRaptor

      • Integration Procedure



    Common Mistakes (Avoid These)

    ❌ Missing @api decorators

    ❌ Incorrect property mapping

    ❌ Using events instead of omniApplyCallResp()

    ❌ Overwriting entire OmniScript JSON unintentionally


    Best Practices

    • Pass only required data to LWC

    • Avoid large JSON payloads

    • Always merge data carefully

    • Log OmniScript JSON during testing

     
     
     

    Recent Posts

    See All

    © 2024 VlocityGru Blog. All Rights Reserved.

    bottom of page