0

enter image description here

Hello! I just want to get an Id through a current page URL in lightning component...

How to get this id from the component side?

should this work on Aapexpages.currentPage().getParameters().get('Id') ?

6

You need to use this interface: force:hasRecordId

 <aura:component implements="force:lightningQuickAction,force:hasRecordId,force:appHostable,flexipage:availableForRecordHome,force:hasRecordId,force:hasSObjectName" access="global" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<b>This is recordID {!v.recordId} </b><br/>
</aura:componet>

javascript:

 doInit:function(componet,event,helper){
   component.get("v.recordId");
  }

Notes:

  • If component implements force:hasRecordId interface, you no need to add a recordId attribute to the component.

  • The component’s controller can access the ID of the current record from the recordId attribute, using component.get("v.recordId"). The recordId attribute is automatically added to the component by the force:hasRecordId interface.

Read this Link for more Information:

https://developer.salesforce.com/docs/component-library/bundle/force:hasRecordId/documentation

0

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.