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
Rocco SorrentinoRocco Sorrentino 

Advanced Apex Superbadge (PDII) Step 3

Hi all,

I'm getting an error while verifying the step 3:
  • Ensure that page performance is improved by only rerendering the table and error messages when a use clicks the Add button.
I have rerender attribute on the Add button but it doesn't work.
Anyone have an answer?

Thank you.
Best Answer chosen by Rocco Sorrentino
Rocco SorrentinoRocco Sorrentino
Resolved using apex:dataTable

All Answers

Rocco SorrentinoRocco Sorrentino
Resolved using apex:dataTable
This was selected as the best answer
Musunuru SurekhaMusunuru Surekha
Hi Rocco,

I am getting the below error while verifying the setp 3:
Challenge Not yet complete... here's what's wrong: 
Ensure that the PricebookEntries are saved on the standard Pricebook.

When I tested it, PriceBookEntries are inserted with standard Pricebook ID but still receive this error.

Can you please suggest?

Thank you.
sridhar sivaramansridhar sivaraman
@Musunuru Surekha, use Constants.STANDARD_PRICEBOOK_ID for Pricebook2Id.

Hi Rocco, can you please let me know how you solved the  rerendering error in detail.
sridhar sivaramansridhar sivaraman
I solved rerendering problem as below
                    <apex:commandButton action="{!addRows}" value="Add" reRender="orderItemTable,pageMessages"/>
Musunuru SurekhaMusunuru Surekha
Thanks Sridhar. I was able to pass the challenge.
Kurkin AlexandreKurkin Alexandre
Use this 
<apex:page standardController="Product2" extensions="Product2Extension" >
    <apex:sectionHeader title="New Product" subtitle="Add Inventory" />
    <apex:pageMessages id="pageMessages" />
    <apex:form id="form" >
        <apex:actionRegion >
            <apex:pageBlock title="Existing Inventory" >
            <apex:chart height="250" width="350" data="{!Inventory}"> 
            <apex:axis type="Numeric" position="left" fields="data" title="MT WON" />    
            <apex:axis type="Category" position="bottom" fields="name" title="Month"/>            
            <apex:barSeries orientation="horizontal" axis="left" xField="data" yField="name" /> 
            <apex:pageBlock title="New Products" >
                <apex:pageBlockButtons location="top">
                    <apex:commandButton action="{!save}" value="Save" />
                <apex:pageBlockButtons location="bottom">
                    <apex:commandButton action="{!addRows}" value="Add" reRender="orderItemTable,pageMessages"/>

                <apex:dataTable value="{!productsToInsert}" var="p" id="orderItemTable" >
                    <apex:column headerValue="{!$ObjectType.Product2.Fields.Name.Label}" >
                        <apex:inputText value="{!p.productRecord.Name}" />
                    <apex:column headerValue="{!$ObjectType.Product2.Fields.Family.Label}" >
                        <apex:selectList value="{!p.productRecord.Family}" size="1" multiselect="false" >
                        <apex:selectList value="{!p.productRecord.Family}" size="1">
                    		<apex:selectOptions value="{!FamilyOptions}"/>
                    <apex:column headerValue="{!$ObjectType.Product2.Fields.isActive.Label}" >
                        <apex:inputField value="{!p.productRecord.isActive}" />
                    <apex:column headerValue="{!$ObjectType.PriceBookEntry.Fields.UnitPrice.Label}" >
                        <inputText value="{!p.pricebookEntryRecord.UnitPrice}" />
                    <apex:column headerValue="{!$ObjectType.Product2.Fields.Initial_Inventory__c.Label}" >
                        <apex:inputField value="{!p.productRecord.Initial_Inventory__c}" />