I have a page which displays a toast message upon successfully inserting a custom object record. I think it would be appropriate to add the record id, so when I click on it, it will redirect to the standard record detail page. Upon testing, record is still inserting but id displayed on toast becomes undefined.

Here is the snippet of the function where I display the toast message:

createRecord() {

            newCustRecord: this.custRecord
        .then(result => {
            this.custRecord = {};
            // This is where I display message
            this.dispatchEvent(new ShowToastEvent({
                title: 'Success!!',
                message: 'Custom Object Record Created Successfully!!' + this.custRecord.Id,
                variant: 'success'
        .catch(error => {
            this.error = error;

Would appreciate if anyone could help me on this.

  • 2
    It does look like that the support for link has been introduced in LWC components. Check the documentation if that helps. – Jayant Das Jul 6 at 21:52
  • @JayantDas yeah, upon checking support for link has been provided. Followed the tutorial and finally implemented it. Thanks! – Ertyq Jul 8 at 17:37

You're deleting the record from memory this.custRecord = {}; then trying to show it. This won't work. this.custRecord = result; should work, assuming saveCustomObject returns the newly created record.

| improve this answer | |
  • Removed the unnecessary this.custRecord = {}; and resolved the undefined id. For my major issue regarding the link for record detail page, I followed the documentation. Didn't know until now that it had been supported by Salesforce already. Thanks ! – Ertyq Jul 8 at 17:40

Not the answer you're looking for? Browse other questions tagged or ask your own question.