+ Start a Discussion
Albert van GinkAlbert van Gink 

Trailhead Quick start: Create a Lightning Component

Hi,

Trailhead: https://trailhead.salesforce.com/projects/quickstart-lightning-components/steps/quickstart-lightning-components3

Problem saving MyContactList.cmp.
Field_Integrity_Exception: Failed to save MyContactList.cmp: Invalid definition for null:MyContactListComponent: null: Source

MCLC.apxc:
public class MyContactListController {
@AuraEnabled
public static List<Contact> getContacts(Id recordId) {
   return [Select Id, FirstName, LastName, Email, Phone From Contact Where AccountId = :recordId];
}
}

MCL.cmp:
<aura:component controller="MyContactListComponent" implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:attribute name="recordId" type="Id" />
<aura:attribute name="Account" type="Account" />
<aura:attribute name="Contacts" type="Contact" />
<aura:attribute name="Columns" type="List" />
<force:recordData aura:id="accountRecord"
                  recordId="{!v.recordId}"
                  targetFields="{!v.Account}"
                  layoutType="FULL"
                  />
<lightning:card iconName="standard:contact" title="{! 'Contact List for ' + v.Account.Name}">
    <!-- Contact list goes here -->
</lightning:card>
</aura:component>

User-added image

Anyone any idea or suggestion to help?

Thank you, regards, albert
Best Answer chosen by Albert van Gink
sfdcMonkey.comsfdcMonkey.com
hi albert ,
use below component code :
use  controller="MyContactListController"​ not controller="MyContactListComponent"​
<aura:component controller="MyContactListController" implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:attribute name="recordId" type="Id" />
<aura:attribute name="Account" type="Account" />
<aura:attribute name="Contacts" type="Contact" />
<aura:attribute name="Columns" type="List" />
<force:recordData aura:id="accountRecord"
                  recordId="{!v.recordId}"
                  targetFields="{!v.Account}"
                  layoutType="FULL"
                  />
<lightning:card iconName="standard:contact" title="{! 'Contact List for ' + v.Account.Name}">
    <!-- Contact list goes here -->
</lightning:card>
</aura:component>
i hope it helps you.
 Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others
thanks 
sfdcmonkey.com 

 

All Answers

sfdcMonkey.comsfdcMonkey.com
hi albert ,
use below component code :
use  controller="MyContactListController"​ not controller="MyContactListComponent"​
<aura:component controller="MyContactListController" implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:attribute name="recordId" type="Id" />
<aura:attribute name="Account" type="Account" />
<aura:attribute name="Contacts" type="Contact" />
<aura:attribute name="Columns" type="List" />
<force:recordData aura:id="accountRecord"
                  recordId="{!v.recordId}"
                  targetFields="{!v.Account}"
                  layoutType="FULL"
                  />
<lightning:card iconName="standard:contact" title="{! 'Contact List for ' + v.Account.Name}">
    <!-- Contact list goes here -->
</lightning:card>
</aura:component>
i hope it helps you.
 Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others
thanks 
sfdcmonkey.com 

 
This was selected as the best answer
Albert van GinkAlbert van Gink
Thanks! I was confused by

4. Add a reference to the Apex controller, controller="MyContactListComponent", on the aura:component tag.

Regards, albert
Eeva IlamaEeva Ilama
I'm following Piyush Soni's instructions but when trying to save, get the following error message: 

FIELD_INTEGRITY_EXCEPTION
Failed to save MyContactList.cmp: Invalid definition for null:MyContactListController: null: Source

Any ideas on how to get past this? Thanks
Melissa Hill Dees 6Melissa Hill Dees 6
Same problem?
Org DeveloperOrg Developer
same error here. Any suggestions?
Rich FiekowskyRich Fiekowsky
Mine does the same FIELD_INTEGRITY_EXCEPTION too, unless I remove the attribute
controller="MyContactListController"
from the aura:component tag . 
Pardhu ThottempudiPardhu Thottempudi
Failed to save mycontactlist.cmp: Invalid definition for null:mycontactlistcontroller: null: Source
SunilAmarSinghSunilAmarSingh
Please give me solution of that.
User-added image

 
Carol Lowe 3Carol Lowe 3
I'm getting the same error. Could someone please assist with this.
Carol Lowe 3Carol Lowe 3
Hey everyone, I sat with a friend who helped me fix this error.
We redid the first step in the exercise:section to copy for this part of the exercise
When you copy the class information, it saves regardless of spaces after the red letters. I must have originally copied the space after when I did this step. this was why my second step couldnt accept the class name for the exercise to work.
I redid the step, made sure that my new class name had no gaps before or after the red text. It save and I completed the text.
When I then verified the next step, it worked.
SunilAmarSinghSunilAmarSingh
Hi,

I am trying to write trigger  to change the oppotunity's city whenever related account's city updated. but problam is that it producing the error.

User-added image
please check it.
Rich FiekowskyRich Fiekowsky
@SunilAmarSingh That code doesnt throw an error for me. I suggest you copy to a text editor, then close everything, then start over from scratch . Possiblty there is an invisible bad character, or possibly your session has gone awry. 
sushanth b 8sushanth b 8
Even then you face the issue, probably you didn't complete previous step.
https://trailhead.salesforce.com/en/content/learn/projects/quickstart-lightning-components/quickstart-lightning-components2