I am using lightning:recordEditForm and lightning:inputField for creating a new record. this component is being used inside a lightning community builder. When i click the submit button, i am able to create a new record in my custom object. However i need the created record ID as i need to pass it in the URL for the next page.

  • Wouldn't that be your v.recordid itself that get auto-populated ?
    – brovasi
    Feb 6, 2018 at 11:47
  • I am using this inside of a community. so i believe the recordid will be NULL. Feb 6, 2018 at 11:58
  • Is that even supported by community ? I know LDS is not quite supported yet.
    – brovasi
    Feb 6, 2018 at 12:02
  • "Lightning Data Service is only available in Lightning Experience and the Salesforce app. Using Lightning Data Service in other containers, such as Lightning Components for Visualforce, Lightning Out, or Communities isn’t supported. This is true even if these containers are accessed inside Lightning Experience or the Salesforce mobile app, for example, a Visualforce page added to Lightning Experience." from developer.salesforce.com/docs/atlas.en-us.lightning.meta/…
    – brovasi
    Feb 6, 2018 at 12:04
  • But i am able to create a record. Just that i want to get the created record ID. Feb 6, 2018 at 14:11

1 Answer 1


The below code will give us the created record id.

handleSuccess : function(component, event, helper) {
var payload = event.getParams().response;
  • 2
    For those who need more info on it here is a documentation.
    – iloveseven
    Aug 17, 2018 at 16:32
  • I want to add two things: 1. For those who are Apex devs with limited Javascript experience, case is important in this context. console.log(payload.id) will return the record ID; console.log(payload.Id) will return undefined. 2. The documentation linked by iloveseven contains the correct way to retrieve the ID, but it also contains an error: handleSuccess: function(component, event) { var updatedRecord = JSON.parse(JSON.stringify(event.getParams())); console.log('onsuccess: ', updatedRecord.id); } returns undefined. Mar 4, 2019 at 21:19
  • Also, ensure you use lower case "id", and not "Id" as javascript is case sensitive. Mar 6, 2019 at 21:14
  • Just want to know how can i use this in LWC,my requirement is in lwc and it throwing error . Apr 16, 2020 at 7:34

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.