I have a component that drops into a record page sidebar (Lead or Contact). It uses LDS to pull data for the record, including the MobilePhone field.
I'm noticing that if the MobilePhone field is not part of the record layout, it doesn't appear in the LDS data -- even if I specify it in the force:recordData fields. If I call for the data via an Apex handler, it can access the data in the field, just can't get it via LDS.
Here's the code, which specifies FULL layoutType, which I would assume gives me access to everything, but maybe it's only everything that's on a layout. But if you have multiple layouts for an object, which layout?
<force:recordData aura:id="recordLoader"
recordId="{!v.recordId}"
layoutType="FULL"
targetRecord="{!v.record}"
fields="{!v.recordFields}"
targetFields="{!v.simpleRecord}"
targetError="{!v.recordError}"
recordUpdated="{!c.handleRecordUpdated}"
/>
I can't find any documentation that mentions the fact that a field has to be in the layout.
Looking for confirmation/documentation.
Here's my controller. In the doInit, I set the recordFields specified in the LDS. The missing data is in the handleRecordUpdated() method, where I try to access the Lead.MobilePhone field -- it's coming up null, dropping to the else
and giving me an error message.
doInit : function(component, event, helper)
{
// console.log('NewConversationController requireOptIn: ' + component.get("v.requireOptIn"));
var recordId = component.get("v.recordId");
if (recordId != null)
{
if (recordId.indexOf('003') == 0)
{
component.set("v.recordFields", "Name, FirstName, AccountId, MobilePhone");
}
else if (recordId.indexOf('00Q' == 0))
{
component.set("v.recordFields", "Name, FirstName, MobilePhone");
}
}
helper.getNumbers(component, event, helper);
},
handleRecordUpdated : function(component, event, helper)
{
var recordId = component.get("v.recordId");
if (recordId.indexOf('003') == 0)
{
// console.log("🦊 Contact" + JSON.stringify(component.get("v.simpleRecord")));
var Contact = component.get("v.simpleRecord");
if (Contact.MobilePhone != null)
{
component.set("v.Contact", Contact);
var Contacts = component.get("v.Contacts");
Contacts.push(Contact);
component.set("v.Contacts", Contacts);
component.set("v.To", Contact.Name);
component.set("v.ToIcon", "standard:contact");
component.set("v.FirstName", Contact.FirstName);
component.set("v.AccountId", Contact.AccountId);
component.set("v.NeedRecipient", false);
} else{
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
"type": "warning",
"mode": "dismissable",
"duration": 3000,
"message": "No mobile phone number for " + Contact.Name + "."
});
toastEvent.fire();
}
} else if (recordId.indexOf('00Q') == 0)
{
// console.log("🦋 Lead: " + JSON.stringify(component.get("v.simpleRecord")));
var Lead = component.get("v.simpleRecord");
if (Lead.MobilePhone != null)
{
component.set("v.Lead", Lead);
var Leads = component.get("v.Leads");
Leads.push(Lead);
component.set("v.Leads", Leads);
component.set("v.To", Lead.Name);
component.set("v.ToIcon", "standard:lead");
component.set("v.FirstName", Lead.FirstName);
component.set("v.NeedRecipient", false);
} else {
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
"type": "warning",
"mode": "dismissable",
"duration": 3000,
"message": "No mobile phone number for " + Lead.Name + "."
});
toastEvent.fire();
}
}
},