0

I'm trying to complete a Trailhead, but I keep getting the following error:

We can’t find the 'FirstName', 'LastName', and 'Email' fields imported into contactList.js.

I was able to push my code into my dev org, and it works, but Trailhead doesn't notice that I've imported the fields required by the exercise. Can anyone assist?

===== HTML =====

<template>
    <lightning-card>
        <template if:true={contacts.data}>
            <lightning-datatable key-field="Id" data={contacts.data} columns={columns}>
            </lightning-datatable>
        </template>
    </lightning-card>
</template>

===== JS =====

import { LightningElement, wire } from 'lwc';

import FIRST_NAME from'@salesforce/schema/Contact.FirstName';
import LAST_NAME from '@salesforce/schema/Contact.LastName';
import CONTACT_EMAIL from '@salesforce/schema/Contact.Email';
import getContacts from '@salesforce/apex/ContactController.getContacts';

const COLUMNS  = [
    { label: 'First Name', fieldName: FIRST_NAME.fieldApiName, type: 'text' },
    { label: 'Last Name', fieldName: LAST_NAME.fieldApiName, type: 'text' },
    { label: 'Email', fieldName: CONTACT_EMAIL.fieldApiName, type: 'email' }
];

export default class ContactList extends LightningElement {
    columns = COLUMNS;
    @wire(getContacts)
    contacts;
}

===== XML =====

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>48.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__AppPage</target>
    </targets>
</LightningComponentBundle>

1 Answer 1

3

Simple oversight. I figured it out this weekend. I was missing a space:

import FIRST_NAME from'@salesforce/schema/Contact.FirstName';

should be:

import FIRST_NAME from '@salesforce/schema/Contact.FirstName';

You must log in to answer this question.

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