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
Doug KellsDoug Kells 

Separately-rendered lightning:recordForm Error

I’m running into an issue with the new lightning:recordForm component available in Summer ’18 when more than one separately-rendered component uses the same method to retrieve a different list of fields.

Basic example: Let’s say you have one component
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,force:hasSObjectName" access="global" >
    <aura:attribute name="recordId" type="String" />
   <aura:attribute name="fields" type="List" default="HomePhone,DoNotCall,Fax,HasOptedOutOfFax"/>
Then there is an identical component with different fields:
<aura:attribute name="fields" type="List" default="Name,Phone,Email,HasOptedOutOfEmail"/>
You then put these on a lightning record page for your contacts and put them within your Tabs (or Accordion) component. If both components are placed in the same tab, they both render fine when that tab becomes active.

Here’s the issue. If I put them into different tabs, only the one in the first of the tabs that is opened renders properly. When you open the second tab, the recordForm component returns an error: “This record could not be loaded because it includes too many formula fields with complex formulas….”

Has anyone else tried this? Is this expected functionality? Is there a workaround?
Dimitri MitsiosDimitri Mitsios
Hello Doug ,
I have an issue with the new lightning:recordForm component when I want to edit a custom field (the system comes up with an error when I save the record)
I got this inspiration from the video
and my code is a simple one

thanks in any case
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <aura:attribute name ="recordId" type ="Id" default ="" />
    <aura:attribute name ="myfields" type ="String[]"  
                    default =
   <lightning:card iconName="standard:contact" title="Milestones " >
      <lightning:recordForm aura:id="recordViewForm"
                            columns ="2"
Doug KellsDoug Kells
Hi Dimitris,
The code that you have looks generally okay to me. Confirm that you have a method called “handleSuccess” in the component's controller. If not, this would cause an error. You may want something to happen when the save is complete, even if it just a success message. Try adding the following to the controller part of the component:
    handleSuccess : function(component, event, helper) {
        var toastEvent = $A.get("e.force:showToast");
            "title": "Success!",
            "message": "The record has been updated successfully.",
            "type": "success"

If you don't want anything like that to happen after the save, the line of code onsuccess="{!c.handleSuccess}" may be deleted.

Hope this helps. 
Dimitri MitsiosDimitri Mitsios
Thank you very much Doug, I added the method and worked.

I would like to extent it by defining dynamic the field on the component level according to the video

but when I try to use a design file i get the following error
"Failed to save The flexipage:availableForAllPageTypes interface doesn't support these attribute types in the design resource: string[]. The flexipage:availableForRecordHome interface doesn't support these attribute types in the design resource: string[]. : Source"
As you can see in the video works perfect but I can not reproduce it.

    <design:attribute name ="myFields" label="Field List" Description="Comma seperated list of fields" />
Thanks again
Doug KellsDoug Kells
Using the design part for this requires a little more doing. In your component, start by adding a new attribute that is just a plain string, and also add an init method.
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="fieldlist" type="String" default="Name,Cost_Analysis_Status__c"/>
Have your design:attribute's name point to fieldlist instead. Then, back in your controller, we need a doInit method to convert the string into a list (and then reload). Something along these lines: 
doInit : function(component, event, helper) {
        var fields = [];
        var fl = component.get("v.fieldlist").split(",");
        fl.forEach(function(f) {
        component.set("v.myfields", fields);

Etienne DKEtienne DK
 .reloadRecord() is not a function of recordForm,  how does one reload the form?
Alexandre Thizy 9Alexandre Thizy 9
In my case I don't need it.
I have just modify a little bit the doInit like this:
doInit : function(component, event, helper) {
        var fields = [];
        var fl = component.get("v.fieldsToDisplay").replace(/\s+/g, '');
        fl = fl.split(",");

        fl.forEach(function(f) {
        component.set("v.fieldsDisplay", fl);

Alexandre Thizy 9Alexandre Thizy 9
Also doable in 2 lines:
var fl = component.get("v.fieldsToDisplay").replace(/\s+/g, '').split(",");
component.set("v.fieldsDisplay", fl);