function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
WalidWalid 

Display a Formula field in a Lightning Component that is hidden in the Page Layout

Hi there,

I built a simple Lightning Component that display field of a record. The fields that I want to display in the component are all Formula fields, and I want to hide them in the Page Layout. When I hide them, the fields show as blank in the Lightning Component!! The only way to oversome this is to show the fields in the Page Layout.

Is there a way to show these fields in the Lightning Component and NOT in the Page Layout? 

Note that I am using the below to display the field in the component:
<div class="slds-col">
   <span>Deficiency<ui:outputRichText value="{!v.ConstRecord.Deficiency_Status__c}" /></span>
</div>

Thanks.
Walid 
krisstannum1krisstannum1
Is the field-level security of the field still read only to your profiles?
WalidWalid
Hi krisstannum1.

These are all Formula fields, so they are all Read Only fields. If I remove them from the Layout, they won't show on the Lightning Component. But my problem is that I don't want them to be on the Component AS WELL AS on the page layout.

Any advice?
Thanks.Walid

 
Matthew Wolfe 13Matthew Wolfe 13
If you use the <force:recordData/>, you can pull in specific fields rather than the fields available on the layout. 

https://developer.salesforce.com/docs/component-library/bundle/force:recordData/documentation
 
<aura:component implements="force:hasRecordId,flexipage:availableForRecordHome">
    <aura:attribute name="accountRecord" type="Object"/>
    <aura:attribute name="recordLoadError" type="String"/>
    
    <force:recordData aura:id="recordLoader"
        recordId="{!v.recordId}"
        fields="Name,Description,Phone,Industry"
        targetFields="{!v.accountRecord}"
        targetError="{!v.recordLoadError}"
    />
    
    <div> 
        <lightning:card iconName="standard:account" title="{!v.accountRecord.Name}" >
            <div class="slds-p-horizontal--small">
                <p class="slds-text-heading--medium"><lightning:formattedPhone title="Phone" value="{!v.accountRecord.Phone}" /></p>
                <p class="slds-truncate"><lightning:formattedText title="Description" value="{!v.accountRecord.Description}" /></p>
                <p class="slds-truncate"> <lightning:formattedText title="Industry" value="{!v.accountRecord.Industry}" /></p>
            </div>
        </lightning:card>
    </div>
</aura:component>