0

Getting below error in calling LWC inside the Omniscript.

enter image description here

below in my LWC

import { LightningElement,track } from 'lwc';
import { OmniscriptBaseMixin } from 'omnistudio/omniscriptBaseMixin';
import pubsub from 'omnistudio/pubsub';

export default class LwcForCraCalculation extends OmniscriptBaseMixin(LightningElement) {
    @track 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)  ); 
    }
    
}
2
  • is there any workaround ?
    – Shekher
    Commented Jun 30, 2023 at 6:00
  • Have you tried enabling Lightning Web Security for LWC under session settings? According to this article it might solve the issue. Commented Jul 3, 2023 at 4:39

2 Answers 2

0

Add runtimeNamespace tag in your meta.xml.

Ex:

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>57.0</apiVersion>
    <isExposed>true</isExposed>
    <runtimeNamespace>omnistudio</runtimeNamespace>
</LightningComponentBundle>
0

Try using connectedCallback instead of renderedCallback. The connectedCallback() is triggered when the component is added to the DOM. It's perfect for initializing component data, setting up event listeners, or fetching data. The renderedCallback() is invoked after the component has been rendered, making it suitable for post-render logic.

connectedCallback(){
        //register the pubsub event
        pubsub.register('omniscript_step', {
            data: this.handleOmniStepLoadData.bind(this),
        });
    }

You must log in to answer this question.

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