0

I am doing the following module in Trailhead- Build a Conference Management App > Create a Lightning component

I am getting the error - API Name undefined is invalid, did you mean "Speaker__c?"

I have tried pasting the exact codes but it still failed -

SpeakerForm.cmp

<aura:component implements="flexipage:availableForRecordHome,force:appHostable,lightning:actionOverride,force:hasRecordId">
<aura:attribute name="speaker" type="Speaker__c" />
<aura:attribute name="recordId" type="String" />
<div class="slds-p-bottom_large slds-p-left_large" style="width:600px">
    <lightning:recordEditForm aura:id="recordViewForm"
                              recordId="{!v.recordId}"
                              recordTypeId="{!v.speaker}"
                              objectApiName="Speaker__c"
                              onsuccess="{!c.onSuccess}">
        <lightning:messages />
        <lightning:inputField fieldName="First_Name__c" />
        <lightning:inputField fieldName="Last_Name__c" />
        <lightning:inputField fieldName="Email__c" />
        <lightning:inputField fieldName="Bio__c" />
        <lightning:button aura:id="submit" type="submit" label="Update Speaker" class="slds-m-top_medium" />
    </lightning:recordEditForm>
</div>

SpeakerFormController.js

({
onSuccess: function(component,event,helper){
    //Show Success message on upsertion of record
    var resultToast = $A.get("e.force:showToast");
    resultToast.setParams({
                        "title": "Success!",
                        "message": "Record Saved Successfully"
                    });
    resultToast.fire();
    //Navigate to sObject home page
    var homeEvent = $A.get("e.force:navigateToObjectHome");
    homeEvent.setParams({
        "scope": "Speaker__c"
    });
    homeEvent.fire();
}})

I have passed the challenge but the form just does not work (it does not even load).

Please help me understand what's wrong.

6
  • 1
    do you have a object called Speaker__c?
    – m Peixoto
    Apr 9, 2019 at 15:10
  • maybe the error is here -> recordTypeId="{!v.speaker}"
    – m Peixoto
    Apr 9, 2019 at 15:12
  • First, check if the object Speaker__c has a Record Type created. If not, I you should create. After, change the line recordTypeId="{!v.speaker}" by recordTypeId="{!v.RecordTypeID}". It is my guess. Another option is delete this line....
    – m Peixoto
    Apr 9, 2019 at 15:22
  • @mPeixoto I do have the object Speaker__c. Also, I did remove the line itself but still the error remains the same.
    – Vikash
    Apr 9, 2019 at 17:02
  • When/Where are you getting this error?
    – Jayant Das
    Apr 9, 2019 at 17:57

1 Answer 1

1

The trailhead was changed in Spring '19 to "Create an Aura Component".

Not loading components is usually due to the browsers tracker or cookie settings, or plugins/add-ons or proxies that protect your privacy. For me Firefox tracker blocking shield in the address bar needed to be turned off.

Salesforce Help page "Troubleshoot issues with Mozilla Firefox"

https://help.salesforce.com/articleView?id=000312847&language=en_US&type=1&mode=1

I got the successful toast message, but for navigating to the object home I got the error on homeEvent

in Chrome:

"Uncaught Action failed: c:SpeakerForm$controller$onSuccess [Cannot read property 'setParams' of undefined]"

in Firefox:

TypeError: Action failed: c:SpeakerForm$controller$onSuccess [homeEvent is undefined]

It turns out somehow the homeEvent definition you had was correct and in the challenge this was changed to "standard_objectPage". which leads to the same error message.

var homeEvent = $A.get("e.force:navigateToObjectHome");

https://developer.salesforce.com/docs/component-library/bundle/force:navigateToObjectHome/documentation

This site is temporarily in read-only mode and not accepting new answers.

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