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
acl5acl5 

inputFields that are rendered based on formula logic don't post to controller when saving

Hi all. 

 

I am working on customizing the quote object to better serve our business needs.  I've added some custom fields to the QuoteLineItem object, Maximum_Volume__c, Minimum_Quantity__c, and Expiration_Date__c.  Each line item will have a value in only one of these fields, but not necessarily the same field. 

 

I'm defining the rendered value based on a PickList Value and updating the VF page using actionSupport.  The VisualForce page works fine, except when the page posts the values entered in the respective fields are not passed to the controller.  If I force a second action on the page(I pushing a command button that doesn't do anything), the second time the values are passed to the controller so I toyed around a little bit....

 

If I reRender the entire pageBlockSection with my actionSupport method, the values post to the controller as I would expect.  The problems with this is that for each line item, I have to select a values from the picklist and and then all of my input fields are cleared.

 

It seems my issue has something to do with the way I am causing the fields to be rendered, but I don't know how to get around it.  I am using a controller extension, but the page uses the standard getters and setters for the quoteLineItems.

 

I would appreciate any suggestions

 

<apex:page standardController="Quote" extensions="newQuoteExt" recordSetVar="OpportunityLineItems" id="page">
  <apex:sectionHeader title="Quote" subtitle="New Special Pricing Agreement"/> 
  <style type="text/css">
        .exceptionText { font-style:italic; font-weight:bold; color:red;}
  </style>
  <apex:messages styleClass="exceptionText"/>
  
  <apex:form >  
    <apex:pageBlock id="block" >
      <apex:pageBlockButtons >
        <apex:commandButton value="Save" action="{!Save}"/>
        <apex:commandButton value="Cancel" action="{!Cancel}"/>
         <apex:commandButton value="test" action="{!updateAgreementType}"/>
      </apex:pageBlockButtons>
      
      <apex:pageBlockSection title="Quote Information">
        <apex:inputField value="{!theQuote.Name}"/>
        <apex:inputField value="{!theQuote.Status}"/>
        <apex:outputField value="{!opportunity.Name}"/>
        <apex:outputField value="{!opportunity.Account.Name}"/>
        <apex:inputField value="{!theQuote.Description}"/>
      </apex:pageBlockSection>
      <apex:actionRegion >
      <apex:pageBlockSection title="Customer Information" id="custinfo">
        <apex:inputField value="{!theQuote.ContactId}"  id="contact">
          <apex:actionSupport action="{!updateContact}" event="oncomplete" reRender="custinfo"/>
        </apex:inputField>
        <apex:inputField value="{!theQuote.Phone}" id="phone">
          <apex:actionSupport action="{!updateContact}" event="onchange" reRender="custinfo"/>
        </apex:inputField>
        <apex:inputField value="{!theQuote.Email}" id="email"/>
        <apex:inputField value="{!theQuote.Fax}" id="fax"/>
 

      </apex:pageBlockSection> 
      </apex:actionRegion>
      <apex:pageBlockSection title="Address Information">
        <apex:inputField value="{!theQuote.BillingName}"/>
        <apex:inputField value="{!theQuote.ShippingName}"/>
        <apex:inputField value="{!theQuote.BillingStreet}"/>
        <apex:inputField value="{!theQuote.ShippingStreet}"/>
        <apex:inputField value="{!theQuote.BillingState}"/>
        <apex:inputField value="{!theQuote.ShippingState}"/>
        <apex:inputField value="{!theQuote.BillingPostalCode}"/>
        <apex:inputField value="{!theQuote.ShippingPostalCode}"/>
        <apex:inputField value="{!theQuote.BillingCountry}"/>
        <apex:inputField value="{!theQuote.ShippingCountry}"/>
      
      </apex:pageBlockSection>
      <apex:pageBlockSection title="Product Information" columns="1" id="productsection">
        <apex:pageBlockTable value="{!lineItems}" var="item" columnsWidth="25%,25%,25%">
          
          <apex:column headerValue="Product">
            <apex:outputField value="{!item.PriceBookEntry.ProductCode}"/>
          </apex:column>
          
          <apex:column headerValue="Agreement Type" colspan="2" id="test">
            <apex:dataTable value="{!item}" var="type">
              <apex:column >
               
<!- THIS IS THE AREA GIVING ME TROUBLE -- >
 <apex:actionRegion >
                  <apex:inputField value="{!item.Agreement_Type__c}" required="true">
                    <apex:actionSupport event="onchange" action="{!updateAgreementType}" reRender="test"/>
                  </apex:inputField> 
                </apex:actionRegion>
              </apex:column>
              <apex:column id="test">
              <apex:inputField value="{!item.Maximum_Volume__c}" rendered="{!IF(item.Agreement_Type__c='Maximum Volume',true,false)}" required="{!IF(item.Agreement_Type__c='Maximum Volume',true,false)}" id="max"></apex:inputField> 
              <apex:inputField value="{!item.Minimum_Quanitity__c}" rendered="{!IF(item.Agreement_Type__c='Minimum Quantity',true,false)}" required="{!IF(item.Agreement_Type__c='Minimum Quantity',true,false)}" id="min"> </apex:inputField> 
              <apex:inputField value="{!item.Expiration_Date__c}" rendered="{!IF(item.Agreement_Type__c='Expiration Date',true,false)}" required="{!IF(item.Agreement_Type__c='Expiration Date',true,false)}" id="date">  </apex:inputField>
             
              </apex:column>
            </apex:dataTable>
 
           </apex:column>
<! -- --------------------------------------------- END -->
          <apex:column headerValue="Special Price" >
            <apex:outputField value="{!item.UnitPrice}" id="outPut">
              <apex:inlineEditSupport event="dblclick" />
            </apex:outputField>
          </apex:column>

        </apex:pageBlockTable>
      </apex:pageBlockSection>
    </apex:pageBlock>

   </apex:form>
</apex:page>

 

bob_buzzardbob_buzzard

Not sure I've quite understood your issue 100%, but in this section:

 

<apex:actionRegion >
   <apex:inputField value="{!item.Agreement_Type__c}" required="true">
      <apex:actionSupport event="onchange" action="{!updateAgreementType}" reRender="test"/>
   </apex:inputField> 
</apex:actionRegion>

 As the actionsupport is inside an actionregion component, the changes to any other inputs on the page won't be sent back to the controller.

acl5acl5

Thanks for your reply Bob.  I had a tough time explaining my situation.

 

I understand that using the actionsRegion will only update the memebers in that region.  I'm not expecting the values in the custom fields to be written to the controller when the actionFunction fires. 

 

The issue I'm having is that after the actionFunction fires and the appropriate custom field is rendered when I push a button (to save the records, or just the dummy method) that is not a memeber of an action region, the values in the newly rendered fields aren't passed to the controller.  The page refreshes( with the dummy method, if I hit the save button the records are entered into the database and the custome fields are all null) and the fields are balnk.  If I then re-enter the data into the custom fields and push the button a second time the values are passed to my controller.

 

If I render all three custom fields on page load, instead of rendering only one based on the picklist value, the values get passed to the controller on the first button push.

 

I need the page to only display one custom field for each line item, based on what my user selects from the picklist.

 

Thanks,

Adam

bob_buzzardbob_buzzard

Have you tried rerendering the entire table?  I'm not sure how much success you'll have rerendering a column based on the selection of a single cell elsewhere.  Effectively, each time you pick something from your selectlist, you'll rerender one of the three fields for every row in the table, and as you have used an actionregion you'll be discarding the changes I think.

acl5acl5

Getting the fields to render based on the picklist selection isn't a problem at all.  The problem I'm having is that after I have made my pickllist selections and rendered the appropriate field,  when I call the save method(through a button push), the values that I have endered into the newly rendered fields are not passed to the controller.  The debug statements in my controller show null values for the custom field that was displayed and had data typed into it.  The page refreshes and the correct custom fields are still rendered, but they are blank.   If I re-enter the data in the field and push the save button a second time, the data is passed to the controller without any problems.  The actionRegion should have no impact because I am not using a javaScript event to call the save method, I am using a commandButton outside of the actionRegion.

kka_zzzsaikka_zzzsai

Did you get a chance to find the solution for this problem?

Kavya NeelagiriKavya Neelagiri
I'm having the same problem.  <apex:inputField ...> works fine unless it has, or is surrounded by, a tag with rendered={!some formula}.