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
Nagaraju Mogili 15Nagaraju Mogili 15 

Could not find a component named MyContactList' on the Account record page.

while working on the Trailhead Tasks, I am getting the below error, please anyone advise me anyone on this.

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

<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 am getting the below error.

Challenge Not yet complete... here's what's wrong: 
Could not find a component named MyContactList' on the Account record page.


 
Baba RyanBaba Ryan
Hi @Nagaraju,

You have created the component, but not added to Account-Page. 

Steps as follows :
  1. In Salesforce, click the App Launcher icon and select Accounts tab and select any Account (ex: United Oil & Gas Corp.).  
  2. Click the gear icon (*), then select Edit Page to open the Lightning App Builder.
  3. Drag the MyContactList custom component from the Lightning Components list to the page and place it in the right column.
  4. Click Save.
  5. Click Activate.
  6. Click Assign as Org Default, then click Save.
  7. Click Back to return to the record page. 
#HappyTrailhead
Rayan

 
Nagaraju Mogili 15Nagaraju Mogili 15
Hi Ryan, Thanks for your reply.

The below code I have copied and paste in the component..


<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}">
    <lightning:datatable data="{! v.Contacts }" columns="{! v.Columns }" hideCheckboxColumn="true"/> 
     </lightning:card>
    <aura:handler name="init" value="{!this}" action="{!c.myAction}" />
</aura:component>

==============================================================================================

User-added image

In the Trailhead, I am getting the below error.


The component does not contain the correct lightning:card markup.
 

can you please help me, what I have done wrong here.
AnuSFDCDevloperAnuSFDCDevloper
If you remove the <lightning:datatable .....> you will not get the error "The component does not contain the correct lightning:card markup." Since For verifying it would SF would parse as per the steps given in that spcific unit.

However, am getting the same inital error as u get "Could not find a component named MyContactList' on the Account record page."

Please someone suggest what we need to cross check
Fábio SuzukiFábio Suzuki
Hey,

I faced the same problem and could not find the solution.
What I did, that works for me, was restart the trail in a new org.
SAKTHIVEL MSAKTHIVEL M
Dear All,

Even I'm also faced the same problem and can't find the solution, so created a new playgound and recreated the controller and component and working fine now.

Thanks
Jarrell DunsonJarrell Dunson
Hello... I have the same issue... I've created MyContactListController.apxc and MyContactList.cmp . 
The instructions say: "Click the Setup icon ... to access Setup in Lightning Experience and choose Edit Page to launch App Builder, the Drag your component from the Custom components list and drop it at the top of the right-hand column, above the Activity component."

When I open the United Oil & Gas Corp. record, then select "Edit Page" then *** There are no custom components listed ***  I do not see a component called 'MyContactList' nor 'MyContactListController' ... (see screen shot below).

** For some reason, my developer Sales environment doesn't see my just-build custom components... 

Does anyone have a possible fix for this? 
Thanks
Jarrell
jarrell.dunson@uky.edu 

Here is what I've tried: 
1. I've tried logging out, closing the Chrome browser, logging in...
2. I've tried to change the Apex names, per this link: https://salesforce.stackexchange.com/questions/92847/cant-set-lightning-component-controller:  From MyContactListController to MyContactListControllers  {and have changed the name back again}
3. I've tried to edit the MyContactListController object, per Simon Johnstone 6, on this page: 
https://developer.salesforce.com/forums/?id=9060G000000I8W9QAK

public class MyContactListController {
    @AuraEnabled
    public static List<Contact> getContacts(Id recordId) {
        List<Contact> cs = [SELECT Id,
                                   FirstName,
                                   LastName,
                                   Email,
                                   Phone
                            FROM   Contact
                            WHERE  AccountId = :recordId
                           ];
        return cs;
    }
}

User-added image
Pankaj ShakyaPankaj Shakya
Solving this challenge into a new Trailhead Playground worked for me.
Abhishek Trivedi 8Abhishek Trivedi 8
I think you might have missed to set the Account Record page as org default page.
To do this: Clicking the activation button > Set as org default.
This has resolved the problem for me.