0

Let us suppose that I go to a record. Then I am editing its page by adding a custom component on the page.

Now I would like to be able to get a record id in the custom component which was added to the page. How can I do that?

3

You implement the force:hasRecordId interface on your component:

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId">

From there, you can get the ID at any point:

doInit: function(component, event, helper) {
  var recordId = component.get("v.recordId");
  // ...

Do not put your own attribute called recordId in to your component; it is defined by the force:hasRecordId interface for you automatically. You can read more in this developer blog post and in the documentation.

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.