1

I am trying to add global action on my lightning component I have embedded my component to contact detail lightning page but I am a getting the below error enter image description here

Please find the code below :

Component

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" controller="LightningContactController" access="global" >
    <aura:handler name="init" action="{!c.getContactList}" value="{!this}"/>
    <aura:attribute name="ContactList" type="List"/>
    <lightning:card title="Contacts" >
        <p class="slds-p-horozintal_small">
        <aura:iteration items="{!v.ContactList}" var="contact">
            <lightning:recordViewForm recordId="{!contact.Id}" objectApiName="Contact">
                <div class="slds-box slds-theme_default">
                    <lightning:outputfield fieldName="Name"/>
                    <lightning:outputfield fieldName="Phone"/>
                    <lightning:outputfield fieldName="Email"/>
                </div>
            </lightning:recordViewForm>    
            <br/>
        </aura:iteration>
        </p>
        <aura:set attribute="actions">
            <lightning:button label="New" onclick="{!c.newContact}"/>
        </aura:set>
    </lightning:card>
</aura:component>

................................................................................

Controller.js

({
    getContactList : function(component, event, helper) {
        helper.fatchcontects(component, event, helper);
    },
    newContact: function(component, event, helper){
        var createContact= $A.get("e.force:createRecord");
        createContact.setParams({
            'entityApiName':'Contact',
            'deFaultFiedlValues' : {
                'AccountId': componet.get("v.recordId")
            }
        });
        createContact.fire();
    }
})

1 Answer 1

1

The error is in your Controller.js

There is a typo. You wrote 'componet' instead of 'component'.

See commented line below:

({
    getContactList : function(component, event, helper) {
        helper.fatchcontects(component, event, helper);
    },
    newContact: function(component, event, helper){
        var createContact= $A.get("e.force:createRecord");
        createContact.setParams({
            'entityApiName':'Contact',
               'defaultFieldValues' : {
            // incorrect spelling of parameter.
            // 'deFaultFiedlValues' : {
              //  error in next line
              //  'AccountId': componet.get("v.recordId")
                  'AccountId': component.get("v.recordId")
            }
        });
        createContact.fire();
    }
})

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.