0

I have a lightning component that is using the NavigationMixin to create a new record from a screen flow. Below is how the component looks.

enter image description here

When a I select "New Account" from the screenflow, the NavigationMixin does not fire anything.

lookupComonent.js

handleNewRecordClick(event) {
    const objectApiName = event.currentTarget.dataset.sobject;
    const selection = this.newRecordOptions.find((option) => option.value === objectApiName);

    const preNavigateCallback = selection.preNavigateCallback
        ? selection.preNavigateCallback
        : () => Promise.resolve();
    preNavigateCallback(selection).then(() => {
        this[NavigationMixin.Navigate]({
            type: 'standard__objectPage',
            attributes: {
                objectApiName,
                actionName: 'new'
            },
            state: {
                defaultFieldValues: selection.defaults
            }
        });
    });

Is there a workaround for creating records from screen flows?

1 Answer 1

2

You missed the attributename called objectApiName in your code:-

    this[NavigationMixin.Navigate]({
        type: 'standard__objectPage',
        attributes: {
            objectApiName : objectApiName,
            actionName: 'new'
        },
        state: {
            defaultFieldValues: selection.defaults
        }
    });

Also, Check this LWC - NavigationMixin From Flow

I have a working example here - https://salesforcediaries.com/2022/01/06/lwc-inside-flow-with-custom-footer/

You must log in to answer this question.

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