Salesforce has 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?
e.force:XXX
events