function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Biswojeet Ray 11Biswojeet Ray 11 

Lightning record creation Issue

Hi Team,

 

I have created a Button on a Lightning page. 

In that button added standard logic to create a budget Item object record.

Code

this[NavigationMixin.Navigate]({
            type: "standard__objectPage",
            attributes: {
                objectApiName: "Budget_Item__c",
                actionName: "new"
            },
            state: {
                nooverride: '1',
                defaultFieldValues: fieldValues
            }
        });


Its creating records perfectly. But the Issue is after the creation of record, It's navigating to a newly created record's detail page.

I want to stay on the previous page only(where I have added the button), No need to navigate the newly created record's detail page.

Is there any workaround? Urgently needed.

 

Thanks in advance,

David Zhu 🔥David Zhu 🔥
Since you already have the fields and value to create a new record, I would suggest create a Apex method to create the record. In lwc, call the apex method imperatively, it will stay on the current page after.
Biswojeet Ray 11Biswojeet Ray 11

Ho @david

 

Is there anything we can do in this piece of code means in LWC code?

 

Thanks,