salesforcesky.com

Learn Salesforce Anywhere Anytime

Theme Switch

Aura Interfaces

Loading

force:appHostable – This interface will make your Lightning Aura component available to be used as a tab in the Lightning Exp or the Salesforce Mobile Application

Here is the sample code 

<!--HelloWorld.cmp-->
<aura:component implements="force:appHostable">

    <!-- Message -->
    <h1>Hello world Here is the example 
how you uses force:appHostable interface in 
your Lightning Component</h1>

</aura:component>

Force:hasRecordId – force:hasRecordId lets the Component get the Id of the Record on the component you placed over the record detail page.

For example, If you placed a component over a record detail page and I want the Id of the record for some particular tasks.

How to use it with Aura Component?

force:hasRecordId adds an attribute of name recordId, containing the value of 18-character Id, i.e., Salesforce Id.

Attribute – You can understand attribute as a variable used to store data for the scenarios.

If the component uses force:hasRecordid, then you don’t need to add this attribute by yourself, and if you added it already, you need to make sure you don’t change the access level and the type of the attribute if not, then you will hit a runtime error.

<aura:attribute name="recordId" type="String" />

NOTE: force:hasRecordid will not work when you are invoking a component from global action. Or you are invoking an element from a header or footer of the experience builder, even if the builder contains the record on that page. 

Sample Code: 

<aura:component implements="force:lightningQuickAction,force:hasRecordId">

    <!-- Code to show you how to implement force:hasRecordId -->

</aura:component> 

Force:hasSObjectName – force:hasSObjectName lets the Component get the of the API name of current record’s sObject type.

We usually use this interface when we are dealing with multiple sObject types.

How to use it with Aura Component?

If the component uses Force:hasSObjectName, then you don’t need to add this attribute by yourself, and if you added it already, you need to make sure you don’t change the access level and the type of the attribute if not, then you will hit a runtime error.

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

NOTE: force:hasRecordid will only work in the record context. When you are invoking a component from global action or invoking an element from a header or footer of the experience builder, even if the builder contains the record on that page. 

Sample Code: 

<aura:component implements="force:lightningQuickAction,force:hasSObjectName">

    <!-- Code to show you how to implement force:hasSObjectName -->

</aura:component> 

force:lightningQuickAction –

 this interface is used to make your lightning component available to the Quick Action. If you didn’t use this interface, you could not use it because your Lightning Component is not visible in the lightning or Salesforce mobile application in the Quick Action.

Sample Code

<!--Addition.cmp→

<aura:component implements="force:lightningQuickAction">

    <!-- ADDITION CODE -->

    <lightning:input type="number" name="no1" aura:id="n1" label="No 1"/> +
    <lightning:input type="number" name="no2" aura:id="n2" label="No 2"/>

    <br/>
    <lightning:button label="Addition" onclick="{!c.Add}"/>

</aura:component>

force:lightningQuickActionWithoutHeader –

If you are going to implement force:lightningQuickActionWithoutHeader, you can not implement force:lightningQuickAction within the same component. 

But in this, you don’t have the standard controls like Cancel, etc.

Sample Code – 

<!--Addition.cmp→

<aura:component implements="force:lightningQuickActionWithoutHeader">

    <!-- ADDITION CODE -->

    <lightning:input type="number" name="no1" aura:id="n1" label="No 1"/> +
    <lightning:input type="number" name="no2" aura:id="n2" label="No 2"/>

    <br/>
    <lightning:button label="Addition" onclick="{!c.Add}"/>

</aura:component>

flexipage:availableForAllPageTypes – 

If you want to make your lightning component available for the record pages or any other type of pages, implement this interface right away.

Sample Code –

<aura:component implements="flexipage:availableForAllPageTypes" access="global">
    <aura:attribute name="message" type="String" default="Hello World" access="global" />
    <aura:attribute name="message 2" type="String" default="SalesforceSky" access="global" />

    <div style="box">
      <span class="message">{!v.message}</span>, {!v.message 2}!
    </div>
</aura:component>

flexipage:availableForRecordHome – 

If you want to make your lightning component available for the record pages, only use flexipage:availableForRecordHome.

Sample Code – 

<aura:component implements="flexipage:availableForRecordHome" 
access="global">
    <aura:attribute name="message" type="String" 
default="Hello World" access="global" />
    <aura:attribute name="message 2" type="String" 
default="SalesforceSky" access="global" />

    <div style="box">
      <span class="message">{!v.message}</span>,
 {!v.message 2}!
    </div>
</aura:component>

forceCommunity:availableForAllPageTypes – 

If you want to make your lightning component available to the Experience Builder, you need to implement forceCommunity:availableForAllPageTypes.

Sample Code – 

<aura:component implements="forceCommunity:availableForAllPageTypes
" access="global">
    <aura:attribute name="message" type="String" default="Hello World" access="global" />
    <aura:attribute name="message 2" type="String" default="SalesforceSky" access="global" />

    <div style="box">
      <span class="message">{!v.message}</span>, {!v.message 2}!
    </div>
</aura:component>