1

I have an LWC FSC (flow screen component).

I am trying to subscribe to a CDC event, but the subscription never seems to execute.

The same LWC when displayed on a lightning record page does subscribe to the CDC event.

Is there a restriction that stops FSCs from being able to subscribe to CDC events?

import { LightningElement } from 'lwc';
import { subscribe } from 'lightning/empApi';

export default class MySubscribeTest extends LightningElement {

    subscription;

    connectedCallback() {
        console.log('this definitely runs');
        
        const messageCallback = (response) => {
            console.log('New message received: ', JSON.stringify(response));
        };
        
        // the then/catch blocks are never executed
        subscribe('/data/My_Custom_Object__ChangeEvent', -1, messageCallback)
        .then((response) => {
            // Response contains the subscription information on subscribe call
            console.log(
                'Subscription request sent to: ',
                JSON.stringify(response.channel)
            );
            this.subscription = response;
        })
        .catch((error) => {
            console.dir(error);
        });
    }
}

1 Answer 1

1

Turns out this works fine, but it does NOT work when in debug mode of the flow.

Make sure the flow is saved/activated, then launch it as a user would.

You must log in to answer this question.

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