• Jason Marshall
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 3
    Replies
Re-factored my code from previous units with base lightning components, but receiving this error.  Here's my new form component.  Any help would be much appreciated.

<aura:component >   
    <aura:attribute name="newItem" type="Camping_Item__c"    default="{ 'sobjectType': 'Camping_Item__c',
                         'Name': '',
                         'Price__c': 0,
                         'Quantity__c': 0,                         
                         'Packed__c': false
                       }"/>
 
    <aura:registerEvent name="addItem" type="c:addItemEvent"/>
    <lightning:layout >
        <lightning:layoutItem padding="around-small" size="6">
<div aria-labelledby="newItemForm">

    <!-- BOXED AREA -->
    <fieldset class="slds-box slds-theme--default slds-container--small">

    <legend id="newItemForm" class="slds-text-heading--small 
      slds-p-vertical--medium">
      Add Camping Item
    </legend>

    <!-- CREATE NEW CAMPING ITEM FORM -->
    <form class="slds-form--stacked">          
        <lightning:input aura:id="itemForm" label="Camping Item Name"
                         name="Name"
                         value="{!v.newItem.Name}"
                         required="true"/> 
        <lightning:input type="number" aura:id="itemForm" label="Quantity"
                         name="Quantity"
                         maxlength="16"
                         min="0"
                         step="1"
                         value="{!v.newItem.Quantity__c}"
                         required="true"/>
        <lightning:input type="number" aura:id="itemForm" label="Price"
                         name="Price"
                         min="0"
                         step=".01"
                         value="{!v.newItem.Price__c}"
                         formatter="currency"
                         messageWhenRangeUnderflow="Enter an amount that's at least .01."/>
        <lightning:input type="checkbox" aura:id="itemForm" label="Packed?"  
                         name="Packed"
                         checked="{!v.newItem.Packed__c}"/>
        <lightning:button label="Create Expense" 
                          class="slds-m-top--medium"
                          variant="brand"
                          onclick="{!c.clickCreateItem}"/>
    </form>
  </fieldset>
  <!-- / BOXED AREA -->

</div>
        </lightning:layoutItem>
    </lightning:layout>
</aura:component>
public with sharing class OrdersPageControllerExtension {
    public ApexPages.StandardController sc;
    public final Order__c order;

    public OrdersPageControllerExtension(ApexPages.StandardController stdController) {
        this.sc = stdController;
        if (!Test.isRunningTest()) { 
            stdController.addFields(new List<String>{'Products__c', 'Restaurant_ID__c', 'Gift_Card__c'});
        }
        if (order.Products__c != null) {
            .....
        }
    }
}


System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Order__c.Products__c 

Has anyone else seen this? Is it a bug?

public with sharing class OrdersPageControllerExtension {
    public ApexPages.StandardController sc;
    public final Order__c order;

    public OrdersPageControllerExtension(ApexPages.StandardController stdController) {
        this.sc = stdController;
        if (!Test.isRunningTest()) { 
            stdController.addFields(new List<String>{'Products__c', 'Restaurant_ID__c', 'Gift_Card__c'});
        }
        if (order.Products__c != null) {
            .....
        }
    }
}


System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Order__c.Products__c 

Has anyone else seen this? Is it a bug?