2

I need to start flow from lwc, I am trying to publish a platform event from LWC to start platform event flow. Don't want to use aura flow.

can we use something like import {events} from '@salesforce/events/Event_Name__e' for publish from API doc

create platform event body: { "Printer_Model__c" : "XZO-5" }

1 Answer 1

3

You have two options: - Either empApi or Using Apex. The way you want is not supported in Lightning Web Component.

  • The empApi component provides access to methods for subscribing to a streaming channel and listening to event messages.
  • The empApi component uses a shared CometD-based Streaming API connection, enabling you to run multiple streaming apps in the browser for one user. The connection is not shared across user sessions.
  • In Apex, either you can use EventBus.publish to publish platform events or you can consume the API

Also, Check Emp API Lightning Web Component

2
  • Thanks @sanket for your reply, In emp api there is no publish bus property exposed to UI component. how could we do it?
    – Ragul
    Commented Jan 31, 2021 at 5:33
  • 4
    You'll need to use apex to publish the event. EmpAPI helps us to subscribe only. Commented Jan 31, 2021 at 5:52

You must log in to answer this question.

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