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
mauricio.ramos@corpitalmauricio.ramos@corpital 

Field not rerendering in pageblocktable

Hello,

 

I havea pageblocktable updated from the controller where I list order items. One of the fields is the product lookup (custom made, not the standarad one from SF). I point the inputText of the lookup to a productID__r.Name field of the product and also update some other fields in teh table when teh user changes the product reference. Alont htese rerenders should also be the product name field, but only the other fields are rerendering (description, and price fields). Can anyone tell me where I am coding this wrong???

 

debugging behind the scenes show taht tthe values are correct so the rerendering should be showing the correct values, so therefore I think the problem is in the actual rerendering of the field.

 

 

VF page:

 

 <apex:pageblock title="Sales Order Items"  tabStyle="SCRB_SalesOrder__c" id="SOIpgblk" >  
      <div style="text-align: center;"> <apex:messages style="font-weight: bold; color:red;" /></div>
    <apex:pageBlockButtons location="top" >
       <apex:commandButton action="{!AddSOI}" value="Add New Item" rerender="tablePnl"  disabled="{!NOT(SOsaved)}" id="btnAddSOI" />
    </apex:pageBlockButtons>  
    <apex:actionRegion id="prodUpdate" renderRegionOnly="false">
    <apex:actionFunction name="doUpdateProdData" action="{!updateSearchProductData}" reRender="detailPanel,tablePnl">
            <apex:param id="prodId" value="" name="prodId"/>     
    </apex:actionFunction>
    </apex:actionRegion>
        
    <apex:outputPanel id="tablePnl">  
        <apex:pageblockTable value="{!SOItems}" var="SOI" id="SOIList" >
            
            <apex:column headerValue="Line type" id="ltcol">
              <apex:actionRegion id="lnTypeRgn" renderRegionOnly="false">
                  <apex:inputField value="{!SOI.Line_Type__c}" id="fLineType"  required="true" >
                      <apex:actionSupport event="onblur" reRender="detailPanel,currLineTypefld" action="{!loadSOIDs}" >
                               <apex:param name="currSOIid" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
                               <apex:param name="currSOILT" value="{!SOI.Line_Type__c}" assignTo="{!currLineType}"/>
                      </apex:actionSupport>
                  </apex:inputField>                     
              </apex:actionRegion>
            </apex:column>
            
            <apex:column headerValue="Product" id="prodCol">         
               <apex:actionRegion id="prodRgn">
                    <apex:inputText value="{!SOI.ProductId__r.name}" id="fProd" onFocus="this.blur()" />
                   <apex:commandLink onclick="prodLookup(this.parentNode.parentNode.cells[1].getElementsByTagName('select')[0].options[this.parentNode.parentNode.cells[1].getElementsByTagName('select')[0].selectedIndex].value);" reRender="fProd">
                        <apex:image value="{!$Resource.lookupIcon}"/>
                        <apex:param name="currSOI" value="{!SOI.id}" assignTo="{!currSOIid}"/>
                    </apex:commandLink>  
               </apex:actionRegion>
            </apex:column>  
            <apex:column headerValue="Description">
                <apex:actionRegion id="rgnDesc" renderRegionOnly="false" >
                <apex:inputField value="{!SOI.Description__c}" id="fDescr" >
                        <apex:actionSupport event="onfocus" reRender="detailPanel" action="{!loadSOIDs}">
                               <apex:param name="currSOIid" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
                               <apex:param name="currSOILT" value="{!SOI.Line_Type__c}" assignTo="{!currLineType}"/>
                      </apex:actionSupport>
                   </apex:inputField>
                     </apex:actionRegion>
            </apex:column>               

 

        REMOVED SOME COLUMNS TO SAVE SPACE


            <apex:column headerValue="Profit" >
                <apex:outputField value="{!SOI.Profit__c}" id="fProfit"/>    
            </apex:column>
            <apex:column headerValue="Total Price">
                <apex:outputField value="{!SOI.TotalPrice__c}" id="fTotalPrice"/>
            </apex:column>
            <apex:column headerValue="Line Status" >
                <apex:outputField value="{!SOI.Line_Status__c}" id="fLineStatus"  />
            </apex:column>          
        </apex:pageBlockTable>
    </apex:outputPanel>
   

Best Answer chosen by Admin (Salesforce Developers) 
mauricio.ramos@corpitalmauricio.ramos@corpital

Hello, 

 

THANKS TO EVERYONE WHO PITCHED IN TO HELP ME SOLVE THE ISSUE. I finally solved the problem of the field not updating: see below the udpated controller code:

 

 

if(id == null ) { return null;}
loadCurrProd(id);
PriceBook2 pb = [SELECT Id,IsStandard,Name FROM Pricebook2 WHERE IsStandard = True Limit 1];
pbEntry = [SELECT Id,Pricebook2Id,Product2Id,ProductCode,UnitPrice FROM PricebookEntry WHERE Product2Id = :mProd.Id AND PriceBook2Id = :pb.id Limit 1];
system.debug('###CurrProd lookup: ' + mProd);
currSOI.ProductId__c = mProd.id;
system.debug('###currProd name: ' + currSOI.ProductId__r.Id + ' -- currSOI.ProdId: ' + currSOI.ProductId__c);
currSOI.SalesPrice__c = pbEntry.UnitPrice;
currSOI.Unit_Cost__c = mProd.Unit_Cost__c;
currSOI.Description__c = mProd.Description;
currSOI.Line_Discount_Amount__c= 0;
currSOI.Line_Discount_Pct__c = 0;
currSOI.TotalPrice__c = 0;
currSOI.Quantity__c = 0;
currSOI.Total_Price_bef_Disc__c = 0;
currSOI.Profit__c = 0;
currSOI.ProductID__r.Name = mProd.Name;
//UPSERT CURRSOI to update relationship field for product
upsert currSOI;

 

 

I added that line of code and now it works just fine. I guess you need to actually assign the value to it even though I already assigned the productId at the top. If anyone knows why this is so please let me know as that was the root of the issue!!

 

Best regards,¨

Mauricio

All Answers

Anup JadhavAnup Jadhav

I don't see 'detailPanel' id being set anywhere in the code. Is this intentional? Also, i'd put a space between the 2 comma seperated values.

 

So write it as:

reRender="detailPanel, tablePnl"

 

Hope this helps!

mauricio.ramos@corpitalmauricio.ramos@corpital

Hi thanks for your reply.

 

Yes its intentional, the detailPanel is another pageblock further below that is also affected by a product selection, it should have nothing to do with the problem at hand, I also tried adding a space in between the rerender list but to no luck. The field still does not rerender. Can it be something related to output panels, action regions or the likes?

Anup JadhavAnup Jadhav

Don't put the <apex:actionFunction> inside the <apex:actionRegion> but put the affected panel (that you want to refresh between the <apex:actionRegion> tags. Try this and let me know.

mauricio.ramos@corpitalmauricio.ramos@corpital

Hi,

 

I have done as you suggested and moved the <apexregion> tags around the tablePnl (the one that should be refreshed) but no changes. The field still does not refresh. 

 

 

<apex:actionFunction name="doUpdateProdData" action="{!updateSearchProductData}" reRender="detailPanel, tablePnl" immediate="true">
<apex:param id="prodId" value="" name="prodId"/>
</apex:actionFunction>

<apex:actionRegion id="prodUpdate" renderRegionOnly="false">
<apex:outputPanel id="tablePnl">
<apex:pageblockTable value="{!SOItems}" var="SOI" id="SOIList" >

.......

</apex:pageBlockTable>
</apex:outputPanel>
</apex:actionRegion>


 

Anup JadhavAnup Jadhav

hmm...can you post the new reformatted code? Also, you are sure that there are exceptions thrown during this ajax request. Try using firebug, or chrome developer console to see if something is not right. Also, where is the javascript function doUpdateProdData() called?

 

- Anup

mauricio.ramos@corpitalmauricio.ramos@corpital

Hi,

Below is the complete code( or at least all the parts involved in the product selection), I did not want to add it all since it was quite long and did not want to confuse anyone trying to assist:
The popup code is working because I have tested it with debug logs and javascript alerts checking to see the progress of the data and the correct values are returned to the main VF page. These values are correctly passed into the controller because I checked debug logs and the productId assignment is being made, and behind the scenes the productId__r.name is showing the correct values after I save the record and query it again. Its just not refreshing on the field in the page :(
CONTROLLER CODE:
 public PageReference updateSearchProductData () {
        //get page parameters: Id || Name
        String id = Apexpages.currentPage().getParameters().get('prodId');
        
         if(id == null ) { return null;}
          loadCurrProd(id);
          PriceBook2 pb = [SELECT Id,IsStandard,Name FROM Pricebook2 WHERE IsStandard = True Limit 1];
          pbEntry = [SELECT Id,Pricebook2Id,Product2Id,ProductCode,UnitPrice FROM PricebookEntry WHERE Product2Id = :mProd.Id AND PriceBook2Id = :pb.id Limit 1];
          system.debug('###CurrProd lookup: ' + mProd);
          currSOI.ProductId__c = mProd.id;
          system.debug('###currProd name: ' + currSOI.ProductId__r.Id + ' -- currSOI.ProdId: ' + currSOI.ProductId__c);
          currSOI.SalesPrice__c = pbEntry.UnitPrice;  
          currSOI.Unit_Cost__c = mProd.Unit_Cost__c;
          currSOI.Description__c = mProd.Description;
          currSOI.Line_Discount_Amount__c= 0;
          currSOI.Line_Discount_Pct__c = 0;
          currSOI.TotalPrice__c = 0;
          currSOI.Quantity__c = 0;
          currSOI.Total_Price_bef_Disc__c = 0;
          //UPSERT CURRSOI to update relationship field for product
          upsert currSOI;
          SCRB_SalesOrderLineItem__c tempSOI = [SELECT Contract_Manager__c,Contract_Mgr_Req__c,Contract_Payment_Start_Date__c,
                Contract_Pay_Start_Date_Req__c,Contract_Start_Date_Req__c,Contract_Start_Date__c,Contract_Template__c,
                Contract_Templ_Req__c,Contract__c,Course_No_Req__c,Course_No__c,Course_Start_Date__c,CreatedById,
                CreatedDate,CurrencyIsoCode,Description_2__c,Description__c,ERP_Job_No_Req__c,ERP_Job_No__c,
                ERP_Job_Task_No__c,ERP_Line_No__c,Id,IsDeleted,LastModifiedById,LastModifiedDate,Line_Discount_Amount__c,
                Line_Discount_Pct__c,Line_Status__c,Line_Type_Req__c,Line_Type__c,ListPrice__c,Major_Account__c,
                Merge_to_Contract__c,Merge_To_Serial_No__c,Mrg_to_Contract_Req__c,Mrg_to_Serial_No_Req__c,Name,ProductId__c,
                Product_Name_Req__c,Product_Type_Req__c,Profit__c,Promotion__c,Qty_req__c,QuantityCanceled__c,
                QuantityInvoiced__c,QuantityShipped__c,Quantity__c,RequestedShipmentOn__c,SalesOrderId__c,SalesPrice__c,
                Serial_No_Req__c,Serial_No__c,ShippingMethod__c,SortOrder__c,Special_Deal_No__c,Subscription_End_Date__c,
                Subscription_Start_Date__c,Subscrip_End_Date_Req__c,Subscrip_Start_Date_Req__c,SW_Contract_Req__c,
                SW_Contract__c,SW_Coordinator__c,SystemModstamp,Tax__c,Time_Estimate_Req__c,Time_Estimate__c,TotalPrice__c,
                Total_Price_bef_Disc__c,Unit_Cost__c,VAT_Prod_Posting_Group__c, ProductId__r.Id, ProductId__r.Name, Product_Name__c 
                FROM SCRB_SalesOrderLineItem__c WHERE id = :currSOI.id LIMIT 1];
                
                system.debug('### currSOI SOI ' + currSOI.ProductId__r.Name + ' -- currSOI.ProdId: ' + currSOI.ProductId__c  + ' -- ' + currSOI.Product_Name__c) ;   //here still the old product info
                system.debug('### tempSOI SOI ' + tempSOI.ProductId__r.Name + ' -- tempSOI.ProdId: ' + tempSOI.ProductId__c  + ' -- ' + currSOI.Product_Name__c);   //// THIS DEBUG SHOWS THE CORRECT VALUES
                currSOI = tempSOI;
          //getCurrSOI and update the list
          for(SCRB_SalesOrderLineItem__c soi: SOIs) {
              if(currSOI.id == soi.id) {
                  soi = currSOI;
                  system.debug('###currProd soi: ' + soi.ProductId__r.Name + ' -- soi.ProdId: ' + soi.ProductId__c + ' -- ' + currSOI.Product_Name__c); // THIS DEBUG SHOWS THE CORRECT VALUES
              }
          }
          return null;
    }

 I will add the VF page code in next post as it will not fit in this one.


mauricio.ramos@corpitalmauricio.ramos@corpital
<!--The Javascript that calls the popup for product selection and the action function to pass the returned values into the controller-->
  <script>
var pop;
function prodLookup(lineType){
    baseURL = "/apex/customProdSearchPopup?LineType=" + lineType; 
    pop = window.open(baseURL, "lookup", 500, 480, "width=500,height=480,toolbar=no,status=no,directories=no,menubar=no,resizable=yes,scrollable=yes", true);
    if (window.focus) { pop.focus();}
    return false;
    }
    
function closeLookupPopup (prodId, prodName) {
 // alert ('Result from popup: ' + prodId + ' - ' + prodName + ' POP: ' + pop);
       if (pop != null) {
           pop.top.close(); 
        }  
      //update the Line Item
      updateProdData (prodId);
}

function updateProdData (prodId) {
    doUpdateProdData(prodId);
}                       
</script>
  
    <apex:actionFunction name="doUpdateProdData" action="{!updateSearchProductData}" reRender="detailPanel, tablePnl" immediate="true">
            <apex:param id="prodId" value="" name="prodId"/>     
    </apex:actionFunction>
  
 <apex:actionRegion id="prodUpdate" renderRegionOnly="false">
    <apex:outputPanel id="tablePnl">  
        <apex:pageblockTable value="{!SOItems}" var="SOI" id="SOIList" >
            <apex:column headerValue="Action">
                <apex:commandLink value="Del" action="{!del}" rerender="tablePnl,detailPanel" style="font-weight:bold"  >
                    <apex:param name="delname" value="{!SOI.id}" assignTo="{!currSOIid}"/> 
                </apex:commandLink>
                &nbsp;|&nbsp;
                <apex:commandLink value="Save" action="{!saveSOI}" rerender="tablePnl,detailPanel" style="font-weight:bold"  >
                    <apex:param name="savename" value="{!SOI.id}" assignTo="{!currSOIid}"/> 
                </apex:commandLink>
            </apex:column>                              
            <apex:column headerValue="Line type" id="ltcol">
              <apex:actionRegion id="lnTypeRgn" renderRegionOnly="false">
                  <apex:inputField value="{!SOI.Line_Type__c}" id="fLineType"  required="true" >
                      <apex:actionSupport event="onblur" reRender="detailPanel,currLineTypefld" action="{!loadSOIDs}" >
                               <apex:param name="currSOIid" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
                               <apex:param name="currSOILT" value="{!SOI.Line_Type__c}" assignTo="{!currLineType}"/> 
                      </apex:actionSupport>
                  </apex:inputField>                     
              </apex:actionRegion>
            </apex:column>
            
            <apex:column headerValue="Product" id="prodCol">         
               <apex:actionRegion id="prodRgn">
                    <apex:inputText value="{!SOI.Product_Name__c}" id="fProd" onFocus="this.blur()" />
                   <apex:commandLink onclick="prodLookup(this.parentNode.parentNode.cells[1].getElementsByTagName('select')[0].options[this.parentNode.parentNode.cells[1].getElementsByTagName('select')[0].selectedIndex].value);" reRender="fProd"> 
                        <apex:image value="{!$Resource.lookupIcon}"/>
                        <apex:param name="currSOI" value="{!SOI.id}" assignTo="{!currSOIid}"/> 
                    </apex:commandLink>
                  
               </apex:actionRegion>
            </apex:column>  
            <apex:column headerValue="Description">
                <apex:actionRegion id="rgnDesc" renderRegionOnly="false" >
                <apex:inputField value="{!SOI.Description__c}" id="fDescr" >
                        <apex:actionSupport event="onfocus" reRender="detailPanel" action="{!loadSOIDs}">
                               <apex:param name="currSOIid" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
                               <apex:param name="currSOILT" value="{!SOI.Line_Type__c}" assignTo="{!currLineType}"/> 
                      </apex:actionSupport>
                   </apex:inputField>
                     </apex:actionRegion>
            </apex:column>               
            <apex:column headerValue="Quantity">
                <apex:actionRegion >
                    <apex:inputField value="{!SOI.Quantity__c}"  id="fQTY" >
                     <apex:actionSupport event="onchange" rerender="fDiscAmt,colTest,fTotalPrice,fProfit" action="{!calculateTotalPrice}">
                         <apex:param name="currSOIQty" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
                         </apex:actionSupport>
                    </apex:inputField>
                </apex:actionRegion>
            </apex:column>  
            <apex:column headerValue="Unit Cost" >
                <apex:inputField value="{!SOI.Unit_Cost__c}" id="fUnitCost">
                <apex:actionSupport event="onchange" rerender="fDiscAmt,fTotalPrice,fProfit" action="{!calculateTotalPrice}">
                         <apex:param name="currSOIUC" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
                         </apex:actionSupport>
                </apex:inputField>          
            </apex:column>
            <apex:column headerValue="Sales Price ex VAT">
                <apex:inputField value="{!SOI.SalesPrice__c}" id="fSalesPrice" >
                    <apex:actionSupport event="onchange" rerender="fDiscAmt,fTotalPrice,fProfit" action="{!calculateTotalPrice}">
                         <apex:param name="currSOISP" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
                    </apex:actionSupport>
                 </apex:inputField>
            </apex:column>
            <apex:column headerValue="Line Disc Pct.">
                <apex:inputField value="{!SOI.Line_Discount_Pct__c}" id="fDiscPct">
                    <apex:actionSupport event="onchange" rerender="fDiscAmt,fTotalPrice,fProfit" action="{!calculateTotalPrice}">
                         <apex:param name="currSOIDP" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
                    </apex:actionSupport>
                 </apex:inputField>
            </apex:column>
            <apex:column headerValue="Line Disc Amt.">
                <apex:inputField value="{!SOI.Line_Discount_Amount__c}" id="fDiscAmt">
                <apex:actionSupport event="onchange" rerender="fDiscAmt,fTotalPrice,fProfit" action="{!calculateTotalPrice}">
                         <apex:param name="currSOIDA" value="{!SOI.Id}" assignTo="{!currSOIid}"/>
                    </apex:actionSupport>
                 </apex:inputField>
            </apex:column>           
            <apex:column headerValue="Profit" >
                <apex:outputField value="{!SOI.Profit__c}" id="fProfit"/>    
            </apex:column>
            <apex:column headerValue="Total Price">
                <apex:outputField value="{!SOI.TotalPrice__c}" id="fTotalPrice"/>
            </apex:column>
            <apex:column headerValue="Line Status" >
                <apex:outputField value="{!SOI.Line_Status__c}" id="fLineStatus"  />
            </apex:column>          
        </apex:pageBlockTable>
    </apex:outputPanel>
</apex:actionRegion>
THANKS AGAIN!!!

 

mauricio.ramos@corpitalmauricio.ramos@corpital

Hello, 

 

THANKS TO EVERYONE WHO PITCHED IN TO HELP ME SOLVE THE ISSUE. I finally solved the problem of the field not updating: see below the udpated controller code:

 

 

if(id == null ) { return null;}
loadCurrProd(id);
PriceBook2 pb = [SELECT Id,IsStandard,Name FROM Pricebook2 WHERE IsStandard = True Limit 1];
pbEntry = [SELECT Id,Pricebook2Id,Product2Id,ProductCode,UnitPrice FROM PricebookEntry WHERE Product2Id = :mProd.Id AND PriceBook2Id = :pb.id Limit 1];
system.debug('###CurrProd lookup: ' + mProd);
currSOI.ProductId__c = mProd.id;
system.debug('###currProd name: ' + currSOI.ProductId__r.Id + ' -- currSOI.ProdId: ' + currSOI.ProductId__c);
currSOI.SalesPrice__c = pbEntry.UnitPrice;
currSOI.Unit_Cost__c = mProd.Unit_Cost__c;
currSOI.Description__c = mProd.Description;
currSOI.Line_Discount_Amount__c= 0;
currSOI.Line_Discount_Pct__c = 0;
currSOI.TotalPrice__c = 0;
currSOI.Quantity__c = 0;
currSOI.Total_Price_bef_Disc__c = 0;
currSOI.Profit__c = 0;
currSOI.ProductID__r.Name = mProd.Name;
//UPSERT CURRSOI to update relationship field for product
upsert currSOI;

 

 

I added that line of code and now it works just fine. I guess you need to actually assign the value to it even though I already assigned the productId at the top. If anyone knows why this is so please let me know as that was the root of the issue!!

 

Best regards,¨

Mauricio

This was selected as the best answer
Anup JadhavAnup Jadhav

Well done. Glad to be of service, sir! Just realized that I had a brain fart earlier when I suggested moving the action region. For some reason i thought it would impact rerender, when it just demarcates the region for Ajax.