0

I am trying to get the data from the Omniscript and put it into the LWC Javascript. But when i check in console it is showing undefined.As I am putting the JSON.parse as well it is throwing an error.

**Javascript Code**
import { OmniscriptBaseMixin } from 'vlocity_ins/omniscriptBaseMixin';
export default class BroliPricingLWC extends OmniscriptBaseMixin(LightningElement) {
const jsonData = JSON.stringify(this.omniJsonData);
        //const jsonData = JSON.stringify(this.omniJsonData);
        console.log('jsonData',jsonData);

}

1 Answer 1

0

I am sorry I am quite late on answering this but you need to make the following configuration changes to pass the data from your OmniScript to your custom LWC:

  1. Click on the Step in which you have added the custom LWC
  2. Open the Messaging Framework section and select the checkbox Pub/Sub
  3. For the Key, enter some variable name e.g. omniJsonData
  4. For the Value, enter the merge syntax for your parent node (which you defined in your Extract Output Path) e.g. %Account%

**5. Please ensure that you activate the OmniScript version before testing the custom LWC, since this feature only works with active OmniScripts.

Thereafter you can update your code as follows:

import { LightningElement } from 'lwc';
import { OmniscriptBaseMixin } from 'vlocity_ins/omniscriptBaseMixin';
import pubsub from 'vlocity_ins/pubsub';

export default class BroliPricingLWC extends OmniscriptBaseMixin(LightningElement) {

    jsonData; 

    renderedCallback(){

        //register the pubsub event
        pubsub.register('omniscript_step', {
            data: this.handleOmniStepLoadData.bind(this),
        });
    }
    
    handleOmniStepLoadData(data) {
        // perform logic to handle the pubsub data from the Step

        //console.log('pubsub data -- '+ JSON.stringify(data)  ); 
        this.jsonData = data.omniJsonData ;         
        console.log('jsonData -- '+ JSON.stringify(this.jsonData)  ); 
    }
    
}

Reference: https://help.salesforce.com/s/articleView?id=sf.os_communicate_with_omniscript_from_a_lightning_web_component_11509.htm&type=5

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .