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
Tyler ZikaTyler Zika 

Event Reference undefined

Salesforce has a set functions that do a lot of basic web app functionality for you, called Event Reference. They can be found here https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_events.htm

On the editRecord Event Reference, found here
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_force_editRecord.htm

essentaily, I create a 
<ui:button label="Edit" press="{!c.editRecord}"/>

on my component, reference the attribute on the page and add the function from the docs in the controller
    editRecord : function(component, event, helper) {
        var editRecordEvent = $A.get("e.force:editRecord");
        console.log("record id is: "component.get("v.item.Id"));
        console.log("editRecordEvent value is: "editRecordEvent);
        editRecordEvent.setParams({
            "recordId": component.get("v.item.Id")
        });
        editRecordEvent.fire();
   }
correct?

Here is the odd thing. From the console.logs, I get the record id, but the editRecordEvent returns undefined. What is going on? Is there something I need to reference in my component to use Event Reference?
 
Tyler ZikaTyler Zika
//edit in my code
editRecord : function(component, event, helper) {
        var editRecordEvent = $A.get("e.force:editRecord");
        console.log("record id is: " + component.get("v.item.Id"));
        console.log("editRecordEvent value is: " + editRecordEvent);
        editRecordEvent.setParams({
            "recordId": component.get("v.item.Id")
        });
        editRecordEvent.fire();
   }