Loading
Salesforce now sends email only from verified domains. Read More
Help Agent Performance DegradationRead More
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Communicate from Omniscript to a Lightning Web Component

          Communicate from Omniscript to a Lightning Web Component

          Send data from Omniscript actions and steps to other Lightning web components using the Publish and Subscribe property.

          Before you begin, review the documentation on using PubSub. See Communicate Between Components.

          Note
          Note The pubsub module doesn’t operate when the Standard Runtime is enabled. Work around this limitation by using window post message (wpm) or session storage message (ssm). For more information, see Message with Window Post Messages and Session Storage Messages.

          The Pub/Sub property enables Action and Step elements to send data in key-value pairs to other Lightning web components. Lightning web components must register the Omniscript component's event name and add code to handle the data sent from the event.

          1. In an Omniscript action or step, in the Properties panel, under Messaging Framework, select Pub/Sub.
          2. In the Key and Value fields, configure which data to pass to another Lightning web component.
            1. For Key, enter a name to store the value.
            2. For Value, enter data to pass to the Lightning web component. The field accepts merge syntax.

              Action Example

              Step Example

              Pass data from the action's response in the Value field using merge syntax. For example, to pass the response node "accountId", enter %accountId% for the value.

              Pass data from an element within the step using merge syntax. For example, to pass a text element named Text1, enter %Text1% for the value.

          3. Activate the Omniscript.
          4. In an Lightning web component that receives data from the Action or Step, import the pubsub module.
            import pubsub from 'namespace/pubsub';
          5. In the Lightning web component, register the pubsub event using this code without replacing anything. The even must register after the component renders.

            Action pubsub Event

            Step pubsub Event

            pubsub.register('omniscript_action', {
                data: this.handleOmniAction.bind(this),
            });
            pubsub.register('omniscript_step', {
                data: this.handleOmniStepLoadData.bind(this),
            });
          6. In the Lightning web component, create a pubsub event handler.

            Action Event Handler Example

            Step Event Handler Example

            handleOmniAction(data) {
              // perform logic to handle the Action's response data
            }
            handleOmniStepLoadData(data) {
              // perform logic to handle the pubsub data from the Step
            }
          7. (Optional) If different actions or steps require different logic, use a switch statement to describe how to handle the event. For information on switch statements, seeswitch.

            Action Example

            Step Example

            Access the action's Element Name using data.name.

            handleOmniAction(data) {
              switch(data.name) {
                case 'SomeNameForAction':
                  this.handleSomeNameForAction(data);
                  break;
                case 'SomeNameForAction2':
                  this.handleSomeNameForAction2(data);
                  break;
                default:
                  // handle default case
              }
            }
            
            handleSomeNameForAction(data) {
                // perform some logic specific to SomeNameForAction action
                // that has element name = "SomeNameForAction"
            }
            
            handleSomeNameForAction2(data) {
                // perform some logic specific to SomeNameForAction2 action
                // that has element name = "SomeNameForAction2"
            }

            Access the step's Element Name using data.name.

            handleOmniStepLoadData(data) {
              switch(data.name) {
                case 'FirstStep':
                  this.handleOmniFirstStepLoadData(data);
                  break;
                case 'SecondStep':
                  this.handleOmniSecondStepLoadData(data);
                  break;
                default:
                  // handle default case
              }
            }
            
            handleOmniFirstStepLoadData(data) {
                // perform some logic specific when a Step element which name is
                // FirstStep is loaded
            }
            
            handleOmniSecondStepLoadData(data) {
                // perform some logic specific when a Step element which name is
                // SecondStep is loaded
            }

            Access the action's Element Type using data.type.

            handleOmniAction(data) {
              switch(data.type) {
                case 'Integration Procedure Action':
                  this.handleIPActionPubsubEvents(data);
                  break;
                case 'Remote Action':
                  this.handleRemoteActionPubsubEvents(data);
                  break;
                default:
                  // handle default case
              }
            }
            
            handleIPActionPubsubEvents(data) {
                // perform some logic specific to Integration Procedure Actions
            }
            
            handleRemoteActionPubsubEvents(data) {
                // perform some logic specific to Remote Actions
            }

            n/a

           
          Loading
          Salesforce Help | Article