I have the following data table. My intention is get the highlighted Lightning:Icon render only if the Lightning component called as a standalone Lightning app. I have this same component exposed in Opportunity Lightning component and I do not want to expose Action section. I thought of using aura:if but for that I need to get the app name on the inIt of the component. How can I get the app name? Or is there a better way of handling this use case?

I also thought decoupling as separate component(only the Action part) and include the Searcher Express component and not in Opportunity component.

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasSObjectName" controller="KF_CompanyLookupController">
         <aura:attribute name="sObjectName" type="String" />
        <table aura:id="companyList" class="slds-table slds-table--bordered slds-table_cell-buffer slds-max-medium-table--stacked-horizontal slds-hide" role="listbox">
                <tr >
                    <th colspan="4" scope="col">
                        <aura:if isTrue="{!v.searching}">
                            <div role="status" class="slds-spinner slds-spinner_large slds-spinner_brand ">
                                <span class="slds-assistive-text">Searching for Companies</span>
                                <div class="slds-spinner__dot-a"></div>
                                <div class="slds-spinner__dot-b"></div>
                        <div class="slds-grid">
                            <div class="slds-col slds-align-bottom">
                                <p class="slds-text-body--small page-header__info">{!v.SECompanies.length} Record(s)</p>
                <tr class="slds-text-heading--label">
                    <aura:if isTrue="{!v.sObjectName!='Opportunity'}">
                        <th scope="row" class="nobordertop">Action</th>
                    <th scope="col" class="nobordertop">Protection Info
                    <th scope="col" class="nobordertop">Company ID</th>
                    <th scope="col" class="nobordertop">Company</th>
                    <th scope="col" class="nobordertop">Ultimate Parent Co</th>
                    <th scope="col" class="nobordertop">Street</th>
                    <th scope="col" class="nobordertop">Address</th>
                <aura:iteration items="{!v.SECompanies}" var="company" indexVar="rowIndex">
                    <tr >
                        <aura:if isTrue="{!v.sObjectName!='Opportunity'}">
                            <td >
                                <lightning:buttonMenu onselect="{!c.handleSelect}" alternativeText="Toggle menu">
                                    <lightning:menuItem label="Edit" value="menuitem1" iconName="action:edit" />
                                    <lightning:menuItem label="New Opportunity" value="menuitem2" iconName="action:new_opportunity" />
                                <lightning:icon class="icon" iconName="action:edit" variant="bare" size="xx-small" title="Edit SE Company"/>
                        <td  data-label="Protection Info" title="Protection Info">
                            <button data-protectdesc="{!company.protectionDesc}" class="slds-button slds-button--icon-border-filled slds-button--icon-border-small" onclick="{!c.handleIconClick}">
                                <lightning:icon class="icon" iconName="{!company.protectionImageSource}" variant="warning" size="small" title="Click to view protection information"/>
                        <td data-label="Company ID" title="Company ID">
                            <div><a data-record="{!company.companyId}" >{!company.companyId}</a></div>
                        <td data-label="Company Name" title="Company Name">
                            <button class="slds-button slds-button-neutral" onclick="{!c.companySelected}" data="{!company}" role="option">{!company.companyName}</button>
                        <td data-label="Ultimate Parent Name" title="Ultimate Parent Name">
                            <div><a data-record="{!company.ultimateParentName}" >{!company.ultimateParentName}</a></div>
                        <td data-label="Street" title="Street">
                            <div><a data-record="{!company.street1}" >{!company.street1}</a></div>
                        <td data-label="Address" title="Address">
                            <div><a data-record="{!company.address}" >{!company.address}</a></div>

enter image description here

  • The best way I could think of would be to create two diffent components. One is embeded in your tab. The other one is called on the opportunities record page. Each of this new Lightning component could insert your current component and set one of its Boolean attribute to: "is in the tab" or "is not in the tab". Commented Jul 24, 2017 at 15:14
  • How can we determine Boolean to be true or false based "is in the tab" or "is not in the tab"?
    – user28452
    Commented Jul 24, 2017 at 15:25
  • Because you can create two different components which call the one you already created. One knows that it will be embeded in a tab so it can set the boolean to true. The other one know that it will embeded in the record page so it can put the boolean to false. Commented Jul 24, 2017 at 15:29
  • No problem. Maybe someone will come with a better solution. Commented Jul 24, 2017 at 15:33
  • 1
    When the component is inside the Opportunity record detail page, recordId attribute will contain the Opp Id, whereas if it runs inside a standalone app then former is empty. So presence of value in recordId will help to decided whether to show/hide the actions columns.
    – Praveen
    Commented Jul 24, 2017 at 17:15

1 Answer 1


If you implement in your component force:hasRecordId then the recordId attribute would have the id that you are in. If the component is not in a record home - this value would be empty.

Also, if you implement in your component force:hasSObjectName then the sObjectName attribute would have the object api name. Also here - if the component is not in a record home - this value would be empty:

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

    <aura:if isTrue="{! v.recordId}">
        <!-- do your stuff -->

    <aura:if isTrue="{! v.sObjectName}">
        <!-- do your stuff -->
  • Update working code for reference.
    – user28452
    Commented Aug 1, 2017 at 7:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .