0

I need to get the sobject's API name in the lightning JS controller, in the component side we need to specify <aura:attribute name="sObjectName" type="String" />, but to access in controller, can some one please say. For recordId, we do this,

action.setParams({
    "accountId": component.get("v.recordId")
});
DanielBarbarian
  • 5,093
  • 12
  • 35
  • 44
Rashmi S
  • 156
  • 7

1 Answers1

0

You need to implement force:hasSObjectName in your component as below

<aura:component implements="force:hasRecordId,force:hasSObjectName" access="global" >

Then in your JS controller you can retrieve the name as below

var name = component.get("v.sObjectName"); // gives you the sObject name
var name = component.get("v.recordId"); // gives you the id of the sObject
Rockstar
  • 2,228
  • 3
  • 20
  • 39