I want to edit a record in lightning then I created this component. The reason because I'm not using the standard because I want to have control when the user clicks on save.


<force:recordEdit aura:id="edit" recordId="{!v.recordId}"/>
<ui:button label="Save" press="{!c.save}"/>


 save : function(component, event, helper) {
        component.find("edit").get("e.recordSave").fire(); // Works in record home page but not in a lightning component



When I added the component in a record home is working but when I calling the same component from a VF that doesn't work. I'm opening the lightining component in the following way. Notice this component will be opened in Lightning Experience

var stringToEncode = '{"componentDef":"c:myComponent","attributes":{"recordId":"a02D0000006V8Ni"}}';
var encodedData = window.btoa(stringToEncode);
window.parent.location = '/one/one.app#' + encodedData; 

component.find("edit").get("e.recordSave") returns null

  • Is the {v.recordId} a typo? It should be {!v.recorId} you are missing the binding operator ! – Rao Jul 25 '17 at 21:22
  • Did you ever find out why get("e.recordSave") is returning null? Facing the same problem. – Daniel Flippance Sep 19 '17 at 18:46
  • I've just noticed that immediately after I upload a new change to Salesforce and refresh the browser, get("e.recordSave") returns a good object. If I then do some testing in the browser and force a browser refresh again without deploying to Salesforce, get("e.recordSave") then always returns null. Then every time I deploy a new build to Salesforce, get("e.recordSave") comes back with a good object – Daniel Flippance Sep 19 '17 at 20:20

This is a Lightning Experience and Salesforce1 event only.

This event is handled by the one.app container. It’s supported in Lightning Experience and Salesforce1 only.

Ref here

To determine if this event is going to work for you, you need to use one of the Visualforce globals and pass it into your component - or get it from your apex controller.

Controller code:

public static getUIThemeDescription() {
  return UserInfo.getUiThemeDisplayed();

JS Controller action handler:

if (result == 'Theme4d') {
  //do stuff
  • Thanks but I knew that. It's in lightning experience. – Carlos Iribar Jul 26 '17 at 15:37
  • No, that's not true. You said in your question that you called the component from VF. By definition, you are NOT in Lightning Experience if in a VF page, no matter how you accessed that page. It's a different namespace and the even you are trying to fire does not exist within it. – Caspar Harmer Jul 26 '17 at 17:35
  • Sorry but It's calling the component from a VF but is not on a VF. If you see my code window.parent.location = '/one/one.app#' + encodedData is redirecting to LEX. /one/one.app opens a page in LEX. – Carlos Iribar Jul 26 '17 at 19:50

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.