Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

220
Views
NoErrorObjectAvailable for a lwc

HTML

<template>
    <lightning-card>
        <lightning-record-form object-api-name={objectApiName}
            onsuccess = {handleSuccess}
            fields={CONTACT_FIELDS}> 
        </lightning-record-form>
    </lightning-card>
</template>

JS

import { LightningElement} from 'lwc';
import CONTACT_OBJECT from '@salesforce/schema/Contact';
import FIRST_NAME_FIELD from '@salesforce/schema/Contact.FirstName';
import LAST_NAME_FIELD from '@salesforce/schema/contact.LastName';
import EMAIL_FIELD from '@salesforce/schema/contact.Email';
import {showToastEvent } from 'lightning/platformShowToastEvent'
export default class ContactCreator extends LightningElement {
    objectApiName = CONTACT_OBJECT;
    CONTACT_FIELDS = [FIRST_NAME_FIELD,LAST_NAME_FIELD,EMAIL_FIELD];
    handleSuccess(event){
        const toastEvent = new showToastEvent({
            title: "Contact Created",
            message: event.detail.id,
            variant: "success"
        });
        this.dispatchEvent(toastEvent);
    }
}

Now when I use the component to create a contact record I receive the following error:

[NoErrorObjectAvailable] Script error.
a()@https://static.lightning.force.com/ap27/auraFW/javascript/nj61v-uP3bGswhb-VTdr6Q/aura_prod.js:1025:196
{anonymous}()@https://static.lightning.force.com/ap27/auraFW/javascript/nj61v-uP3bGswhb-VTdr6Q/aura_prod.js:1025:389
dispatchEvent()@https://static.lightning.force.com/ap27/auraFW/javascript/nj61v-uP3bGswhb-VTdr6Q/aura_prod.js:21:32794
P.dispatchEvent()@https://static.lightning.force.com/ap27/auraFW/javascript/nj61v-uP3bGswhb-VTdr6Q/aura_prod.js:21:8008
P.handleSuccess()@https://resourceful-raccoon-s4pqyc-dev-ed.lightning.force.com/components/lightning/recordForm.js:1:7969

I already am using event.detail correctly so what am I missing?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

JavaScript is case sensitive so when you are importing import {showToastEvent } from 'lightning/platformShowToastEvent' make sure that you use import {ShowToastEvent } from 'lightning/platformShowToastEvent' ( Capital 'S' )

import { LightningElement} from 'lwc';
import CONTACT_OBJECT from '@salesforce/schema/Contact';
import FIRST_NAME_FIELD from '@salesforce/schema/Contact.FirstName';
import LAST_NAME_FIELD from '@salesforce/schema/contact.LastName';
import EMAIL_FIELD from '@salesforce/schema/contact.Email';
import {ShowToastEvent  } from 'lightning/platformShowToastEvent'
export default class Test1 extends LightningElement {


objectApiName = CONTACT_OBJECT;
fields = [FIRST_NAME_FIELD,LAST_NAME_FIELD,EMAIL_FIELD];
handleSuccess(event) {
  
    const evt = new ShowToastEvent ({
        title: 'Contact created',
        message: 'Record ID: ' + event.detail.id,
        variant: 'success',
    });
    this.dispatchEvent(evt);
}
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!