• Joe Xu 7
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 7
    Replies
I'm trying to pass value for <apex:inputField> to wrapper class, but it doesn't work. The form does show the data from wrapper class which I think the get() is working but not the set(). I have turned on debug log and none of the changes (on the input field) has been passed on to the controller. Could someone point out where the problem is?

VF page:
<apex:pageBlockSection title="Meal Options" columns="1">
                <!-- Choose which product family-->
                <apex:actionRegion >
                    <apex:selectList value="{!SelectedProdFamily}" multiselect="false" size="1">
                        <apex:actionSupport event="onchange" action="{!applyFilter}" reRender="myProdList"/>
                        <apex:selectOptions value="{!ProdFamily}" > 
                            Product Family:  
                        </apex:selectOptions>
                    </apex:selectList>
                </apex:actionRegion>
                
                <!-- Product options table with pagination -->
                <apex:pageBlock >
                    <!--Table of available products and quantity -->
                    <apex:pageBlockTable value="{!selectProds}" var="sp" align="center" id="myProdList">
                         <!-- below is the input field which doesn't pass on the value to the binding wrapper class-->
                        <apex:column headerValue="Quantity">
                            <apex:inputField value="{!sp.mItem.Quantity__c}" required="true"/>
                        </apex:column>
                        <apex:column value="{!sp.pd.name}"/>
                        <apex:column value="{!sp.pd.Family}"/>
                        <apex:column value="{!sp.pd.Grams_of_Protein__c}"/>
                        <apex:column value="{!sp.pd.Grams_of_Fat__c}"/>
                        <apex:column value="{!sp.pd.Grams_of_Carbohydrates__c}"/>
                        <apex:column value="{!sp.pd.Quantity_Remaining__c}" />
                    </apex:pageBlockTable>
                    <!-- Button panel for product form-->
                    <apex:pageBlockButtons location="bottom">
                        <apex:outputPanel id="myButtons">
                            <apex:commandButton action="{!First}" title="First" value="|<First" disabled="{!disablePrevious}" reRender="myProdList,myButtons"/>
                            <apex:commandButton action="{!Previous}" title="Previous" value="Previous" disabled="{!disablePrevious}" reRender="myProdList,myButtons"/>
                            Page {!pageNumber} of {!totalPages}
                            <apex:commandButton action="{!Next}" title="Next" value="Next" disabled="{!disableNext}" reRender="myProdList,myButtons"/>
                            <apex:commandButton action="{!Last}" title="Last" value="Last>|" disabled="{!disableNext}" reRender="myProdList,myButtons"/>
                        </apex:outputPanel>
                    </apex:pageBlockButtons>
                </apex:pageBlock>
            </apex:pageBlockSection>
Controller:
public PageReference applyFilter(){
        
        Meal_Item__c temp = new Meal_Item__c();
        if(MealItems.size()>0){
            For(ProductOptionData p : SelectProds){
                    system.debug('test'+p.pd.id);
                    system.debug('test'+p.mItem.Quantity__c);
            }
        }
        SelectProds = SelectProds();
        return null;
    }

//Wrapper class
    Public class productOptionData{
        Public Product2 pd{get;set;}
        Public Meal_Item__c mItem{get;set;}
        
        public productOptionData(Product2 pd, Meal_Item__c mItem){
            this.pd = pd;
            this.mItem = mItem;
        }
    }


 
Hi, I'm doing Trailhead course: Lightning Components Basics (Input Data Using Forms) and hitting below error:

"Something has gone wrong. Action failed: aura$iteration$controller$itemsChange [Cannot read property 'apply' of undefined] Failing descriptor: {aura$iteration$controller$itemsChange}. Please try again."

Here is my campingList.cmp:
<aura:component >
    <aura:attribute name="newItem" type="Camping_Item__c"
                    default="{ 'sobjectType': 'Camping_Item__c',
                             'Name': '',
                             'Quantity__c': 0,
                             'Price__c': 0,
                             'Packed__c': false}"/>
    
    <aura:attribute name="items" type="Camping_Item__c[]"/>
    <div aria-labelledby="newcampingitemform">
        
        <!-- BOXED AREA -->
        <fieldset class="slds-box slds-theme--default slds-container--small">
            
            <legend id="newcampingitemform" class="slds-text-heading--small 
                                                   slds-p-vertical--medium">
                Add Camping Item
            </legend>
            
            <!-- CREATE NEW CAMPING ITEM FORM -->
            <form class="slds-form--stacked">
                
                <div class="slds-form-element slds-is-required">
                    <div class="slds-form-element__control">
                        <ui:inputText aura:id="name" label="Name"
                                      class="slds-input"
                                      labelClass="slds-form-element__label"
                                      value="{!v.newItem.Name}"
                                      required="true"/>
                    </div>
                </div>
                
                <div class="slds-form-element slds-is-required">
                    <div class="slds-form-element__control">
                        <ui:inputNumber aura:id="quantity" label="Quantity"
                                        class="slds-input"
                                        labelClass="slds-form-element__label"
                                        value="{!v.newItem.Quantity__c}"
                                        required="true"/>
                        
                    </div>
                </div>
                
                <div class="slds-form-element">
                    <div class="slds-form-element__control">
                        <ui:inputCurrency aura:id="price" label="Price"
                                          class="slds-input"
                                          labelClass="slds-form-element__label"
                                          value="{!v.newItem.Price__c}"
                                          required="true"/>
                    </div>
                </div>
                
                <div class="slds-form-element">
                    <div class="slds-form-element__control">
                        <ui:inputCheckbox aura:id="packed" label="Packed"
                                          class="slds-input"
                                          labelClass="slds-form-element__label"
                                          value="{!v.newItem.Packed__c}"/>
                    </div>
                </div>
                
                <div class="slds-form-element">
                    <ui:button label="Create Camping Item"
                               class="slds-button slds-button--brand"
                               press="{!c.clickCreateNewCampingItem}"/>
                </div>
            </form>
            <!-- / CREATE NEW CAMPING ITEM FORM -->
            
        </fieldset>
        <!-- / BOXED AREA -->
    </div>
    
    <!-- /SHOW LIST OF CAMPING ITEM  -->
     <div class="slds-card slds-p-top--medium">
        <header class="slds-card__header">
            <h3 class="slds-text-heading--small">Camping Items</h3>
        </header>
        
        <section class="slds-card__body">
            <div id="list" class="row">
                <aura:iteration items="{!v.items}" var="i">
                    <c:campingListItem item="{!i}"/>
                </aura:iteration>
            </div>
        </section>
    </div> 
   <!-- /SHOW LIST OF CAMPING ITEM  -->
</aura:component>
And below is campingListItem.cmp:
<aura:component>
    <aura:attribute name="item" type="Camping_Item__c"/>
    <p>Name:
        <ui:outputText value="{!v.item.name}"/>
    </p>
    <p>Price:
        <ui:outputCurrency value="{!v.item.Price__c}"/>
    </p>
    <p>Quanity:
        <ui:outputNumber value="{!v.item.Quantity__c}"/>
    </p>
    <p>Packed:
        <ui:outputCheckbox value="{!v.item.Packed__c}"/>
    </p>
</aura:component>

I can see the error happens in below code within campingList.cmp:
<aura:iteration items="{!v.items}" var="item">
                    <c:campingListItem item="{!item}"/>
                </aura:iteration>
And once I replace it with below code, the error doesn't happen any more. Can someone help check what's wrong with my nest component code. Thanks!
<aura:iteration items="{!v.items}" var="item">
                     <aura:attribute name="item" type="Camping_Item__c"/>
                     <p>Name:
                         <ui:outputText value="{!item.name}"/>
                     </p>
                     <p>Price:
                         <ui:outputCurrency value="{!item.Price__c}"/>
                     </p>
                     <p>Quanity:
                         <ui:outputNumber value="{!item.Quantity__c}"/>
                     </p>
                     <p>Packed:
                         <ui:outputCheckbox value="{!item.Packed__c}"/>
                     </p>
                 </aura:iteration>
Hi, I'm trying to create an Onclick JavaScript custom button (as List Button for multi-record action) and hitting below error:

"sObject type 'sObject' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names."

This button is put on Account object's related list and the target object is filepicker__File__c which is from managed package. When I select filepicker__File__c records from Account's related list view, and click this custom button, it shows above error.

Below is my JavaScript:
{!REQUIRESCRIPT("/soap/ajax/31.0/connection.js")}
var records = {!GETRECORDIDS($ObjectType.filepicker__File__c)};
var files = [];
if (records.length == 0) {
   alert("Please select at least one record to update.");     
} else {
      for (var a=0; a<records.length; a++) {
         var file = new sforce.SObject("filepicker__File__c");
         file.filepicker__id = records[a].filepicker__id;
         file.filepicker__AU_Access__c = "Yes";
         files.push(file);
      }
      result = sforce.connection.update([files]);  

if (result[0].success == 'false') {
alert(result[0].errors.message);
}
else {
location.reload(true); /* redisplay the detail page */
}
  }

Can someone help find out the cause? Thank you!
I'm trying to pass value for <apex:inputField> to wrapper class, but it doesn't work. The form does show the data from wrapper class which I think the get() is working but not the set(). I have turned on debug log and none of the changes (on the input field) has been passed on to the controller. Could someone point out where the problem is?

VF page:
<apex:pageBlockSection title="Meal Options" columns="1">
                <!-- Choose which product family-->
                <apex:actionRegion >
                    <apex:selectList value="{!SelectedProdFamily}" multiselect="false" size="1">
                        <apex:actionSupport event="onchange" action="{!applyFilter}" reRender="myProdList"/>
                        <apex:selectOptions value="{!ProdFamily}" > 
                            Product Family:  
                        </apex:selectOptions>
                    </apex:selectList>
                </apex:actionRegion>
                
                <!-- Product options table with pagination -->
                <apex:pageBlock >
                    <!--Table of available products and quantity -->
                    <apex:pageBlockTable value="{!selectProds}" var="sp" align="center" id="myProdList">
                         <!-- below is the input field which doesn't pass on the value to the binding wrapper class-->
                        <apex:column headerValue="Quantity">
                            <apex:inputField value="{!sp.mItem.Quantity__c}" required="true"/>
                        </apex:column>
                        <apex:column value="{!sp.pd.name}"/>
                        <apex:column value="{!sp.pd.Family}"/>
                        <apex:column value="{!sp.pd.Grams_of_Protein__c}"/>
                        <apex:column value="{!sp.pd.Grams_of_Fat__c}"/>
                        <apex:column value="{!sp.pd.Grams_of_Carbohydrates__c}"/>
                        <apex:column value="{!sp.pd.Quantity_Remaining__c}" />
                    </apex:pageBlockTable>
                    <!-- Button panel for product form-->
                    <apex:pageBlockButtons location="bottom">
                        <apex:outputPanel id="myButtons">
                            <apex:commandButton action="{!First}" title="First" value="|<First" disabled="{!disablePrevious}" reRender="myProdList,myButtons"/>
                            <apex:commandButton action="{!Previous}" title="Previous" value="Previous" disabled="{!disablePrevious}" reRender="myProdList,myButtons"/>
                            Page {!pageNumber} of {!totalPages}
                            <apex:commandButton action="{!Next}" title="Next" value="Next" disabled="{!disableNext}" reRender="myProdList,myButtons"/>
                            <apex:commandButton action="{!Last}" title="Last" value="Last>|" disabled="{!disableNext}" reRender="myProdList,myButtons"/>
                        </apex:outputPanel>
                    </apex:pageBlockButtons>
                </apex:pageBlock>
            </apex:pageBlockSection>
Controller:
public PageReference applyFilter(){
        
        Meal_Item__c temp = new Meal_Item__c();
        if(MealItems.size()>0){
            For(ProductOptionData p : SelectProds){
                    system.debug('test'+p.pd.id);
                    system.debug('test'+p.mItem.Quantity__c);
            }
        }
        SelectProds = SelectProds();
        return null;
    }

//Wrapper class
    Public class productOptionData{
        Public Product2 pd{get;set;}
        Public Meal_Item__c mItem{get;set;}
        
        public productOptionData(Product2 pd, Meal_Item__c mItem){
            this.pd = pd;
            this.mItem = mItem;
        }
    }


 
Hi, I'm doing Trailhead course: Lightning Components Basics (Input Data Using Forms) and hitting below error:

"Something has gone wrong. Action failed: aura$iteration$controller$itemsChange [Cannot read property 'apply' of undefined] Failing descriptor: {aura$iteration$controller$itemsChange}. Please try again."

Here is my campingList.cmp:
<aura:component >
    <aura:attribute name="newItem" type="Camping_Item__c"
                    default="{ 'sobjectType': 'Camping_Item__c',
                             'Name': '',
                             'Quantity__c': 0,
                             'Price__c': 0,
                             'Packed__c': false}"/>
    
    <aura:attribute name="items" type="Camping_Item__c[]"/>
    <div aria-labelledby="newcampingitemform">
        
        <!-- BOXED AREA -->
        <fieldset class="slds-box slds-theme--default slds-container--small">
            
            <legend id="newcampingitemform" class="slds-text-heading--small 
                                                   slds-p-vertical--medium">
                Add Camping Item
            </legend>
            
            <!-- CREATE NEW CAMPING ITEM FORM -->
            <form class="slds-form--stacked">
                
                <div class="slds-form-element slds-is-required">
                    <div class="slds-form-element__control">
                        <ui:inputText aura:id="name" label="Name"
                                      class="slds-input"
                                      labelClass="slds-form-element__label"
                                      value="{!v.newItem.Name}"
                                      required="true"/>
                    </div>
                </div>
                
                <div class="slds-form-element slds-is-required">
                    <div class="slds-form-element__control">
                        <ui:inputNumber aura:id="quantity" label="Quantity"
                                        class="slds-input"
                                        labelClass="slds-form-element__label"
                                        value="{!v.newItem.Quantity__c}"
                                        required="true"/>
                        
                    </div>
                </div>
                
                <div class="slds-form-element">
                    <div class="slds-form-element__control">
                        <ui:inputCurrency aura:id="price" label="Price"
                                          class="slds-input"
                                          labelClass="slds-form-element__label"
                                          value="{!v.newItem.Price__c}"
                                          required="true"/>
                    </div>
                </div>
                
                <div class="slds-form-element">
                    <div class="slds-form-element__control">
                        <ui:inputCheckbox aura:id="packed" label="Packed"
                                          class="slds-input"
                                          labelClass="slds-form-element__label"
                                          value="{!v.newItem.Packed__c}"/>
                    </div>
                </div>
                
                <div class="slds-form-element">
                    <ui:button label="Create Camping Item"
                               class="slds-button slds-button--brand"
                               press="{!c.clickCreateNewCampingItem}"/>
                </div>
            </form>
            <!-- / CREATE NEW CAMPING ITEM FORM -->
            
        </fieldset>
        <!-- / BOXED AREA -->
    </div>
    
    <!-- /SHOW LIST OF CAMPING ITEM  -->
     <div class="slds-card slds-p-top--medium">
        <header class="slds-card__header">
            <h3 class="slds-text-heading--small">Camping Items</h3>
        </header>
        
        <section class="slds-card__body">
            <div id="list" class="row">
                <aura:iteration items="{!v.items}" var="i">
                    <c:campingListItem item="{!i}"/>
                </aura:iteration>
            </div>
        </section>
    </div> 
   <!-- /SHOW LIST OF CAMPING ITEM  -->
</aura:component>
And below is campingListItem.cmp:
<aura:component>
    <aura:attribute name="item" type="Camping_Item__c"/>
    <p>Name:
        <ui:outputText value="{!v.item.name}"/>
    </p>
    <p>Price:
        <ui:outputCurrency value="{!v.item.Price__c}"/>
    </p>
    <p>Quanity:
        <ui:outputNumber value="{!v.item.Quantity__c}"/>
    </p>
    <p>Packed:
        <ui:outputCheckbox value="{!v.item.Packed__c}"/>
    </p>
</aura:component>

I can see the error happens in below code within campingList.cmp:
<aura:iteration items="{!v.items}" var="item">
                    <c:campingListItem item="{!item}"/>
                </aura:iteration>
And once I replace it with below code, the error doesn't happen any more. Can someone help check what's wrong with my nest component code. Thanks!
<aura:iteration items="{!v.items}" var="item">
                     <aura:attribute name="item" type="Camping_Item__c"/>
                     <p>Name:
                         <ui:outputText value="{!item.name}"/>
                     </p>
                     <p>Price:
                         <ui:outputCurrency value="{!item.Price__c}"/>
                     </p>
                     <p>Quanity:
                         <ui:outputNumber value="{!item.Quantity__c}"/>
                     </p>
                     <p>Packed:
                         <ui:outputCheckbox value="{!item.Packed__c}"/>
                     </p>
                 </aura:iteration>
Hi, I'm trying to create an Onclick JavaScript custom button (as List Button for multi-record action) and hitting below error:

"sObject type 'sObject' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names."

This button is put on Account object's related list and the target object is filepicker__File__c which is from managed package. When I select filepicker__File__c records from Account's related list view, and click this custom button, it shows above error.

Below is my JavaScript:
{!REQUIRESCRIPT("/soap/ajax/31.0/connection.js")}
var records = {!GETRECORDIDS($ObjectType.filepicker__File__c)};
var files = [];
if (records.length == 0) {
   alert("Please select at least one record to update.");     
} else {
      for (var a=0; a<records.length; a++) {
         var file = new sforce.SObject("filepicker__File__c");
         file.filepicker__id = records[a].filepicker__id;
         file.filepicker__AU_Access__c = "Yes";
         files.push(file);
      }
      result = sforce.connection.update([files]);  

if (result[0].success == 'false') {
alert(result[0].errors.message);
}
else {
location.reload(true); /* redisplay the detail page */
}
  }

Can someone help find out the cause? Thank you!