9

To access data within the a Lightning view, is it necessary to write client controller code that polls a server-side controller?

This makes sense based on my experience in other languages. But I was hoping / thought I read that somehow the immediate object's data - ex. on a record page - would be injected into the view.

11

If this component is being used in the Lightning Experience, you want the component to implement force:hasRecordId, which will give you the the object's id which you can use to query the other related information that you need. The only other field that can be populated in that manner is the name field, which you can get by having your component implement force:hasSObjectName.

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,force:hasSObjectName">
    <aura:attribute name="recordId" type="String" />
    <aura:attribute name="sObjectName" type="String" />

The Lightning Components Developers' Guide has a section on this topic.

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.