Newer Version Available

This content describes an older version of this product. View Latest

Configure Components for Lightning Experience Record Home Pages

With a few tweaks to your component, you can make it work on a record page in Lightning Experience.

Before your component can work on a record page in Lightning Experience, configure the component so it works in Lightning App Builder. See Configure Components for Lightning Pages and the Lightning App Builder for more information.

Once your component is compatible with Lightning App Builder, use these guidelines to adjust it so it works on record pages in Lightning Experience.

Record pages are different from app pages in a key way: they have the context of a record. To make your components display content that is based on the current record, use a combination of an interface and an attribute.

  • If your component is available for both record pages and any other type of page, implement flexipage:availableForAllPageTypes.
  • If your component is designed just for record pages, implement the flexipage:availableForRecordHome interface instead of flexipage:availableForAllPageTypes.
  • If your component needs the record ID, also implement the force:hasRecordId interface.
  • If your component needs the object’s API name, also implement the force:hasSObjectName interface.

If your managed component implements the flexipage or forceCommunity interfaces, its upload is blocked if the component and its attributes aren’t set to access="global". For more information on access checks, see Controlling Access.

Note

force:hasRecordId

Useful for record page components. Implement this interface if you want your component to receive the ID of the currently displaying record.

This interface adds an attribute named recordId to your component. This attribute is of type String, and its value is an 18-character Salesforce record ID, like this: 001xx000003DGSWAA4. Don’t expose the recordId attribute to the Lightning App Builder—don’t put it in the component’s design file. You don’t want admins supplying a record ID.
1<aura:attribute name="recordId" type="String" />

The record ID is populated only when you place the component on a record page. In all other cases, the record ID isn’t populated, such as when you create this component programmatically inside another component.

force:hasSObjectName

Useful for record page components. Implement this interface if your component needs to know the API name of the object of the currently displaying record.

This interface adds an attribute named sObjectName to your component. This attribute is of type String, and its value is the API name of an object, such as Account or myNamespace__myObject__c.

1<aura:attribute name="sObjectName" type="String" />

The sObjectName attribute is populated only when you place the component on a record page. In all other cases, sObjectName isn’t populated, such as when you create this component programmatically inside another component.

Some components only work with a specific object. The mechanism for restricting components to specific objects isn’t yet available. In the meantime, we recommend using the Entity Context to check the object. Then, display a message in the component to gracefully handle the case where the component has been added to an incompatible object page.

Tip