layoutType="FULL"
will fetch the default layout assigned to that user. From LDS Docs, when you specify fields (included/excluded from default page layout), they are also loaded.
The issue (I would rather say the bug in documentation):
fields
attribute will not trigger the reload of record. So, it is better to use conditional rendering. Reason: When record is initially loaded, the fields is not yet set bydoInit
method and when thefields
are set, therecordData
will not reload the record. Ofcourse you can usereloadRecord()
but its not required as you need extra fields. So, if you use conditional rendering (When fields!=null), therecordData
will load ONLY after thefields
are set .- Although documentation shows
fields
attribute asString
, it is actually aList
.
Below is the sample working code with respect to above points:
COMPONENT:
<aura:attribute name="recordFields" type="List" default="[]" />
<aura:attribute name="accountRecord" type="Object"/>
<aura:attribute name="recordLoadError" type="String"/>
<aura:handler name="init" value="{! this }" action="{! c.init }"/>
<div class="slds-theme_default slds-box">
<aura:if isTrue="{!not(empty(v.recordFields))}">
<force:recordData aura:id="recordLoader"
recordId="00128000009j45uAAA"
layoutType="FULL"
fields="{!v.recordFields}"
targetFields="{!v.accountRecord}"
targetError="{!v.recordLoadError}"
/>
Name - {!v.accountRecord.Name}, Active - {!v.accountRecord.Active__c}
</aura:if>
</div>
CONTROLLER JS:
init : function(component, event, helper){
component.set("v.recordFields",['Name','Type','Phone','Active__c','Description']);
},
Note that List
has to be set on fields.