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
Nikki Phillips 8Nikki Phillips 8 

I need ReRender to ignore a required field inside a pageBlockSection when an onChange event is triggered.

I have a custom visual force page that calculates prices when fields are changed. The only problem is I have a required field that does not need to be required in order to do the calculations but is required in order to save.  I'm not great with styling and everything is in the exact spot I need it in using the code I have provided. Is there a way to just ignore that field?
<apex:page standardController="EventPackageRevenueBreakdown__c"
		   extensions="EventPackageRevenueBreakdownExt" standardStylesheets="true"
	<apex:form >
		<apex:sectionHeader title="{!$ObjectType.EventPackageRevenueBreakdown__c.label} {!$}"
							help="{!$Label.NIBaseHelpURL}#cshid= event_package_revenue_breakdown_new">
		<apex:pageBlock mode="edit"
						title="{!$ObjectType.EventPackageRevenueBreakdown__c.label} {!$}">
			<apex:pageblockbuttons >
				<apex:commandbutton action="{!save}" value="{!$Label.Package_Save}"></apex:commandbutton>
				<apex:commandbutton action="{!SaveAndNew}"
				<apex:commandbutton action="{!cancel}"
			<apex:pagemessages ></apex:pagemessages>
			<apex:pageblocksection title="{!$Label.Package_Information}" id="block123">
				<apex:actionFunction name="CalculateInclusive" action="{!CalculateInclusive}"
				<apex:actionFunction name="CalculateExclusive" action="{!CalculateExclusive}"
				<apex:pageBlockSectionItem >
					<apex:outputpanel layout="block" styleClass="requiredInput"></apex:outputpanel>
				<apex:outputpanel layout="block" styleClass="requiredBlock"></apex:outputpanel>
				<apex:inputfield required="true"
								 value="{!EventPackageRevenueBreakdown__c.UnitPrice__c}" label="inclusive label" onChange="CalculateInclusive()">	</apex:inputfield>
				<apex:inputfield required="false"
				<apex:pageBlockSectionItem rendered="{!NOT(showInclusivePrices)}">
					<apex:outputLabel value="{!inclusiveLabel}"></apex:outputLabel>
				<apex:pageBlockSectionItem rendered="{!showInclusivePrices}">
					<apex:outputLabel value="Inclusive Rate"></apex:outputLabel>
					<apex:input type="number" value="{!InclusiveRate}" onChange="CalculateExclusive()"  onkeypress="if (event.keyCode==13) {CalculateExclusive(); return false;} else return true;"></apex:input>
				<apex:inputfield value="{!EventPackageRevenueBreakdown__c.BookingPackageEvent__c}"/>
				<apex:inputfield required="true"
								 value="{!EventPackageRevenueBreakdown__c.RevenueClassification__c}" onChange="CalculateInclusive()"></apex:inputfield>

				<apex:inputfield required="true"
								 value="{!EventPackageRevenueBreakdown__c.Name}"  ></apex:inputfield>
			<apex:pageblocksection title="{!$Label.AdminChargeAndGratuity}">
				<apex:inputfield required="false"
								 value="{!EventPackageRevenueBreakdown__c.AdminCharge__c}" onChange="CalculateInclusive()"></apex:inputfield>
				<apex:inputfield required="false" value="{!EventPackageRevenueBreakdown__c.Gratuity__c}" onChange="CalculateInclusive()"></apex:inputfield>
			<apex:pageblocksection title="{!$Label.InclusivePrice}"
				<apex:inputcheckbox value="{!EventPackageRevenueBreakdown__c.AdminIsIncludedInInclusivePrice__c}" onChange="CalculateInclusive()"></apex:inputcheckbox>
				<apex:inputcheckbox value="{!EventPackageRevenueBreakdown__c.GratuityIsIncludedInInclusivePrice__c}" onChange="CalculateInclusive()"></apex:inputcheckbox>

Atul GuptaAtul Gupta

When you fire an action via a button or command link it submits the entire form, meaning all the required fields in the form are checked, so you're right in saying that targetted re-rendering would not solve your problem. The key is to split up your fields into logical groups, whereby when firing a specific action only the fields you want are included.

You can use <apex:actionRegion> tags to split up the form into various groups of fields with their associated actions—when you fire an action in a region only the fields in that same region are sent.

Althernatively, you are now allowed to have multiple <apex:form>s on the page, and this has the same effect with the added bonus of transferring way less information as it supports multiple view states.
Finally, another option is to use the immeditate="true" attribute and value on your action buttons/links, but this can cause other difficulties so I'd try the above first.
Hi Nikki,

Just throwing this idea out there....   It works for our needs.

If your field is required via a validation rule, a common practice is to have the object trigger set a checkbox (named something like "Ignore_VR__c") to True.   Next,  modify the VR to check for the Ignore_VR__c = True.   Next, write a workflow that sets  Ignore_VR__c to false every time the record is saved (or meets some other criteria of yours. ).

This takes advantage of the Salesforce order of execution - as Validation rules always take precedence over triggers, but workflow happens after everything else.     The only question mark is what happens in your   EventPackageRevenueBreakdownExt page controller, and if you have a trigger on the EventPackageRevenueBreakdown__c object -- and if you do, what does it do?  It might not be a big deal -- but you'll have to look at your code to see how it all fits together.