1

I am trying to display a list of date ranges based on an objects start and end dates using a lightning component. When I open it in a visualforce page as part of a set of nested components, it will not display the input fields. When I inspect, the rendered HTML has a message:

"No input rendered: " "Field "Flight_Start_Date__c" not found in response."

The thing is, I can see the response providing the required field; in the apex controller, in the js controller, and in the lightning component if I use and plug it in in place of the inputField.

EDIT FOR CLARIFICATION: I did this before with a different object and it worked just fine. When I moved the start and end dates to this object and replaced the references, it stopped working.

Here is the component code:

<aura:iteration items="{!v.flights}" var="flight" indexVar="index"> 
  <lightning:recordViewForm recordId="{!flight.Id}" objectApiName="Product_Line_Item_Detail__c"> 
        <lightning:layout>
            <lightning:layoutItem size="12">
                <lightning:layout>
                    <lightning:layoutItem size="2" class="slds-p-top_large slds-p-left_small">
                        <lightning:formattedText value="{!'Flight ' +  (index + 1) + ':'}" style="align:center"/>
                    </lightning:layoutItem>
                    <lightning:layoutItem size="3" class="slds-p-right_small slds-p-left_small">
                        <lightning:inputField type="date" fieldName="Flight_Start_Date__c" value="{!flight.Flight_Start_Date__c}"/>
                    </lightning:layoutItem>
                    <lightning:layoutItem size="3" class="slds-p-right_small slds-p-left_small">
                        <lightning:inputField type="date" fieldName="Flight_End_Date__c" value="{!flight.Flight_End_Date__c}"/>
                    </lightning:layoutItem>
                    <lightning:layoutItem size="2" class="slds-p-top_large">
                        <lightning:button  onclick="{!c.deleteFlight}" label="Delete" value="{!index}" class="slds-button_dual-stateful slds-button_stretch"/>
                    </lightning:layoutItem>
                    <lightning:layoutItem size="2" class="slds-p-top_large">
                        <lightning:button onclick="{!c.updateFlight}" label="Update"  value="{!index}" class="slds-button_dual-stateful slds-button_stretch"/>
                    </lightning:layoutItem>
                </lightning:layout>
            </lightning:layoutItem>
        </lightning:layout>
    </lightning:recordViewForm> 
    <br></br>
    <br></br>
</aura:iteration>

Here is the js controller code to get the flights:

getFlights : function(cmp) {
        var component = cmp;
        var action = component.get("c.getProductFlights");
        action.setParams({productLineItemId : component.get("v.productLineItemId") });
        action.setCallback(this, function(response){
            var state = response.getState();
            if(state == 'SUCCESS') {
                console.log('Got flights');
                console.log('response = ' + JSON.stringify(response.getReturnValue()));
                component.set("v.flights", response.getReturnValue());   
                component.set("v.newStartDate", "");
                component.set("v.newEndDate", "");

            }

        });
        $A.enqueueAction(action);
    }

Here is the apex controller code:

@AuraEnabled
public static Product_Line_Item_Detail__c[] getProductFlights(String productLineItemId){
    Id productId = productLineItemId;
    return [SELECT Id
            , Name
            , Flight_Start_Date__c
            , Flight_End_Date__c
            , Retail_Amount__c
            , Quantity__c
            from Product_Line_Item_Detail__c
            where Product_Line_Item__c =: productId 
            order by flight_start_date__c asc];
}

Edit: I got it to work by replacing the fieldName with the field names of the object I was using before (Old Object Field Name = Start_Date__c vs. Current Object Field Name = Flight_Start_Date__c). Why does this work? I'm afraid it will stop working when I delete the other object.

<lightning:layoutItem size="3" class="slds-p-right_small slds-p-left_small">
    <lightning:inputField type="date" fieldName="Start_Date__c" value="{!flight.Flight_Start_Date__c}"/>
</lightning:layoutItem>
<lightning:layoutItem size="3" class="slds-p-right_small slds-p-left_small">
     <lightning:inputField type="date" fieldName="End_Date__c" value="{!flight.Flight_End_Date__c}"/>
</lightning:layoutItem>
  • Does v.flights property is set with a list properly? – Raul May 2 at 11:45
  • Yes v.flights is defined like this: <aura:attribute name="flights" type="Product_Line_Item_Detail__c[]" access="global" /> – cpullara May 2 at 11:48
  • I actually just got it to work, but I don't understand why. The previous object fields were called Start_Date__c and End_Date__c. When I replace the inputField fieldName with Start_Date__c instead of Flight_Start_Date__c it seems to work again. But I am planning to delete the object that I used before, and I don't know if it will stop working when I do that. – cpullara May 2 at 11:50
  • Put this answer in the official answer to your own question, so others don't think it's still an open question – Brian Miller May 2 at 12:20
  • @BrianMiller It's not an official answer though, it's some weird hacky thing that only works because I set it up that way before. I'd like to know why it doesn't register the new field names. – cpullara May 2 at 12:31
1

I think this is related to caching. I was able to change to the new object field names after a few days and some serious cache clearing efforts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.