I am working on a lightning component where on click contact link I have to open that contact in edit mode. But throwing this error: enter image description here

Please find my code below: I am using it in :

<aura:component > 
    <aura:attribute name="showcontact" type="Contact[]"/>

    <table class="slds-table slds-table--bordered slds-table--cell-buffer" style="margin-top:50px;"> 

        <div style="text-align:center;font-size:25px">
            Selected Contacts

        <tr class="slds-text-heading--label">
            <th scope="col">
                <div class="slds-truncate" title="Contact Name"><b>Contact Name</b></div>
            <th scope="col">
                <div class="slds-truncate" title="Phone"><b>Phone</b></div>
            <th scope="col">
                <div class="slds-truncate" title="Email"><b>Email</b></div>
        <aura:iteration items="{!v.showcontact}" var="con">
                    <a href="javascript:void(0);" onclick="{!c.editContact}" data-value="{!con.Id}">
                    <div class="slds-truncate" >
                    <div class="slds-truncate">


    editContact: function (component, event, helper) {
        var rectarget = event.currentTarget;
        var idstr = rectarget.getAttribute("data-value"); 
        var editRecordEvent = $A.get("e.force:editRecord");
            "recordId": idstr
  • whats the value you are getting in idstr...please use console.log('****',idstr).??? and alsp try o use like this var rectarget = event. event.target.Id; – Annappa PH May 12 '18 at 5:39
  • I am getting contact id here. – SFDC 44 May 12 '18 at 5:42
  • make on Id hard code and check that. I think that you maynot get that error (for testing purpose )something like this:<a onclick="{!c.editContact}" data-conId="0037F00000O7Dj7QAF">0037F00000O7Dj7QAF</a> – Annappa PH May 12 '18 at 5:50
  • 2
    Please note: This event is handled by the one.app container. It’s supported in Lightning Experience, the Salesforce app, and Lightning communities. If you are not in this context, this event won't be available – Caspar Harmer May 12 '18 at 7:15
  • I am using it in : <aura:application extends="force:slds"> <c:ShowContactsOnClickAccount/> </aura:application> How can I show it here ? – SFDC 44 May 12 '18 at 7:18

If you are adding lightning component to a Lightning app and viewing lightning app from developer console then e.force:editRecord do not work because force events are handled only in one/one.app. so please try to add a lightning component to the page using app builder.

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