You need to sign in to do that
Don't have an account?

Make due date as a required field in my visual force page
Hello all,
I have custom visual force page for our case page.
We have two custom checkbox felds called Followup_required and call_back_needed. So when ever one of those fields are checked, I wanted my due date to be a required field.
I wrote this code but it doesnt work
<apex:pageblockSectionItem >
<apex:outputlabel value="{!$ObjectType.Case.fields.ActivityDate__c.label}"/>
<apex:outputPanel id="DueDate">
<apex:inputField value="{!NewCase.ActivityDate__c}" required="{{!Newcase.Are_you_going_to_call_back__c}||{!Newcase.Follow_up_required__c}}"/>
</apex:outputPanel>
</apex:pageblockSectionItem>
This is my visual force page. I highlighted the area of code im having trouble with. Please help
<apex:page tabStyle="case" standardController="contact" extensions="NewCaseController" recordSetVar="Cases">
<apex:sectionHeader title="{!$ObjectType.Case.label}" subtitle="New {!$ObjectType.Case.label}" id="header"/>
<apex:pagemessages id="pgmsgs"/>
<apex:form >
<apex:pageblock title="New Case">
<apex:pageblockButtons >
<apex:commandButton value="Save" action="{!SaveandRedirect}" />
<apex:commandButton value="Cancel" action="{!Cancel}"/>
</apex:pageblockButtons>
<apex:pageblockSection columns="2" title="Case Information" collapsible="false">
<apex:inputfield value="{!NewCase.ContactId}"/>
<apex:pageblockSectionItem >
<apex:outputLabel value="{!$ObjectType.Case.label} Owner"/>
<apex:outputText value="{!$User.FirstName} {!$User.LastName}"/>
</apex:pageblockSectionItem>
<apex:inputfield value="{!NewCase.Origin}" required="true"/>
<apex:inputfield value="{!NewCase.AccountId}"/>
<apex:inputField value="{!NewCase.Type}" required="true"/>
<apex:pageblockSectionItem >
<apex:outputLabel value="ContactPhone" for="contactphone"/>
<apex:outputText value="{!contactphone}" id="contactphone"/>
</apex:pageblockSectionItem>
<apex:inputfield value="{!NewCase.SubType__c}" required="true"/>
<apex:inputfield value="{!NewCase.Subject}" required="true"/>
<apex:inputfield value="{!NewCase.Priority}"/>
<apex:inputfield id="description" value="{!NewCase.Description}" required="true" style="width:400px;height:120px;"/>
<apex:pageblockSectionItem >
<apex:outputlabel value="{!$ObjectType.Case.fields.status.label}"/>
<apex:actionRegion >
<apex:inputfield value="{!NewCase.Status}" required="true">
<apex:actionsupport event="onchange" rerender="pgmsgs, followupfield, callbackfield" action="{!statuschange}"/>
</apex:inputfield>
</apex:actionRegion>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:outputLabel value="Internal Comments" for="internalcomments"/>
<apex:inputTextarea value="{!Internalcomments}" id="internalcomments" style="width:400px;height:120px;"/>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:outputlabel value="{!$ObjectType.Case.fields.Supervisor_Call_Back_Required__c.label}"/>
<apex:inputCheckbox value="{!NewCase.Supervisor_Call_Back_Required__c}"/>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:outputLabel value="This is past 48 hours requirement. Would you still like to proceed?"/>
<apex:inputCheckbox value="{!OverrideActivityValidation}"/>
</apex:pageblockSectionItem>
</apex:pageblockSection>
<apex:pageblockSection columns="1">
<apex:pageblockSectionItem >
<apex:pageblockSection columns="4">
<apex:pageblockSectionItem >
<apex:outputlabel value="{!$ObjectType.Case.fields.Follow_up_required__c.label}"/>
<apex:actionRegion >
<apex:outputPanel id="followupfield">
<apex:inputcheckbox value="{!NewCase.Follow_up_required__c}" disabled="{!Newcase.status == 'Closed'}">
<apex:actionSupport action="{!mutualexclusionrule_followup}" reRender="callbackfield,callbacknumber" event="onchange"/>
</apex:inputcheckbox>
</apex:outputPanel>
</apex:actionRegion>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:outputlabel value="{!$ObjectType.Case.fields.Are_you_going_to_call_back__c.label}"/>
<apex:actionRegion >
<apex:outputPanel id="callbackfield">
<apex:inputcheckbox value="{!NewCase.Are_you_going_to_call_back__c}" disabled="{!Newcase.status == 'Closed'}">
<apex:actionSupport action="{!mutualexclusionrule_cb}" reRender="followupfield,callbacknumber" event="onchange"/>
</apex:inputcheckbox>
</apex:outputPanel>
</apex:actionRegion>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:outputlabel value="{!$ObjectType.Case.fields.Callback_Number__c.label}" />
<apex:outputPanel id="callbacknumber">
<apex:inputField value="{!NewCase.Callback_Number__c}" required="{!Newcase.Are_you_going_to_call_back__c}"/>
</apex:outputPanel>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:outputlabel value="{!$ObjectType.Case.fields.ActivityDate__c.label}"/>
<apex:outputPanel id="DueDate">
<apex:inputField value="{!NewCase.ActivityDate__c}" required="{{!Newcase.Are_you_going_to_call_back__c}||{!Newcase.Follow_up_required__c}}"/>
</apex:outputPanel>
</apex:pageblockSectionItem>
</apex:pageblockSection>
</apex:pageblockSectionItem>
</apex:pageblockSection>
</apex:pageblock>
</apex:form>
</apex:page>
I have custom visual force page for our case page.
We have two custom checkbox felds called Followup_required and call_back_needed. So when ever one of those fields are checked, I wanted my due date to be a required field.
I wrote this code but it doesnt work
<apex:pageblockSectionItem >
<apex:outputlabel value="{!$ObjectType.Case.fields.ActivityDate__c.label}"/>
<apex:outputPanel id="DueDate">
<apex:inputField value="{!NewCase.ActivityDate__c}" required="{{!Newcase.Are_you_going_to_call_back__c}||{!Newcase.Follow_up_required__c}}"/>
</apex:outputPanel>
</apex:pageblockSectionItem>
This is my visual force page. I highlighted the area of code im having trouble with. Please help
<apex:page tabStyle="case" standardController="contact" extensions="NewCaseController" recordSetVar="Cases">
<apex:sectionHeader title="{!$ObjectType.Case.label}" subtitle="New {!$ObjectType.Case.label}" id="header"/>
<apex:pagemessages id="pgmsgs"/>
<apex:form >
<apex:pageblock title="New Case">
<apex:pageblockButtons >
<apex:commandButton value="Save" action="{!SaveandRedirect}" />
<apex:commandButton value="Cancel" action="{!Cancel}"/>
</apex:pageblockButtons>
<apex:pageblockSection columns="2" title="Case Information" collapsible="false">
<apex:inputfield value="{!NewCase.ContactId}"/>
<apex:pageblockSectionItem >
<apex:outputLabel value="{!$ObjectType.Case.label} Owner"/>
<apex:outputText value="{!$User.FirstName} {!$User.LastName}"/>
</apex:pageblockSectionItem>
<apex:inputfield value="{!NewCase.Origin}" required="true"/>
<apex:inputfield value="{!NewCase.AccountId}"/>
<apex:inputField value="{!NewCase.Type}" required="true"/>
<apex:pageblockSectionItem >
<apex:outputLabel value="ContactPhone" for="contactphone"/>
<apex:outputText value="{!contactphone}" id="contactphone"/>
</apex:pageblockSectionItem>
<apex:inputfield value="{!NewCase.SubType__c}" required="true"/>
<apex:inputfield value="{!NewCase.Subject}" required="true"/>
<apex:inputfield value="{!NewCase.Priority}"/>
<apex:inputfield id="description" value="{!NewCase.Description}" required="true" style="width:400px;height:120px;"/>
<apex:pageblockSectionItem >
<apex:outputlabel value="{!$ObjectType.Case.fields.status.label}"/>
<apex:actionRegion >
<apex:inputfield value="{!NewCase.Status}" required="true">
<apex:actionsupport event="onchange" rerender="pgmsgs, followupfield, callbackfield" action="{!statuschange}"/>
</apex:inputfield>
</apex:actionRegion>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:outputLabel value="Internal Comments" for="internalcomments"/>
<apex:inputTextarea value="{!Internalcomments}" id="internalcomments" style="width:400px;height:120px;"/>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:outputlabel value="{!$ObjectType.Case.fields.Supervisor_Call_Back_Required__c.label}"/>
<apex:inputCheckbox value="{!NewCase.Supervisor_Call_Back_Required__c}"/>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:outputLabel value="This is past 48 hours requirement. Would you still like to proceed?"/>
<apex:inputCheckbox value="{!OverrideActivityValidation}"/>
</apex:pageblockSectionItem>
</apex:pageblockSection>
<apex:pageblockSection columns="1">
<apex:pageblockSectionItem >
<apex:pageblockSection columns="4">
<apex:pageblockSectionItem >
<apex:outputlabel value="{!$ObjectType.Case.fields.Follow_up_required__c.label}"/>
<apex:actionRegion >
<apex:outputPanel id="followupfield">
<apex:inputcheckbox value="{!NewCase.Follow_up_required__c}" disabled="{!Newcase.status == 'Closed'}">
<apex:actionSupport action="{!mutualexclusionrule_followup}" reRender="callbackfield,callbacknumber" event="onchange"/>
</apex:inputcheckbox>
</apex:outputPanel>
</apex:actionRegion>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:outputlabel value="{!$ObjectType.Case.fields.Are_you_going_to_call_back__c.label}"/>
<apex:actionRegion >
<apex:outputPanel id="callbackfield">
<apex:inputcheckbox value="{!NewCase.Are_you_going_to_call_back__c}" disabled="{!Newcase.status == 'Closed'}">
<apex:actionSupport action="{!mutualexclusionrule_cb}" reRender="followupfield,callbacknumber" event="onchange"/>
</apex:inputcheckbox>
</apex:outputPanel>
</apex:actionRegion>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:outputlabel value="{!$ObjectType.Case.fields.Callback_Number__c.label}" />
<apex:outputPanel id="callbacknumber">
<apex:inputField value="{!NewCase.Callback_Number__c}" required="{!Newcase.Are_you_going_to_call_back__c}"/>
</apex:outputPanel>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:outputlabel value="{!$ObjectType.Case.fields.ActivityDate__c.label}"/>
<apex:outputPanel id="DueDate">
<apex:inputField value="{!NewCase.ActivityDate__c}" required="{{!Newcase.Are_you_going_to_call_back__c}||{!Newcase.Follow_up_required__c}}"/>
</apex:outputPanel>
</apex:pageblockSectionItem>
</apex:pageblockSection>
</apex:pageblockSectionItem>
</apex:pageblockSection>
</apex:pageblock>
</apex:form>
</apex:page>
Hi,
Try this
<apex:pageBlockSectionItem >
<!-- Your Checkboxes here, onchange should rerender the below section which has your Activity Date--->
<apex:inputField value="{!Newcase.Are_you_going_to_call_back__c}">
<apex:actionSupport event="onchange" reRender="DueDate" />
</apex:inputField>
</apex:pageBlockSectionItem>
<apex:pageblockSectionItem >
<apex:outputlabel value="{!$ObjectType.Case.fields.ActivityDate__c.label}"/>
<apex:outputPanel id="DueDate">
<apex:inputField value="{!NewCase.ActivityDate__c}" required="{!Newcase.Are_you_going_to_call_back__c || Newcase.Follow_up_required__c}"/>
</apex:outputPanel>
</apex:pageblockSectionItem>
Kindly mark this as the answer if you are resolved
Thanks
All Answers
reRender="callbackfield,callbacknumber,DueDate"
Hi,
Try this
<apex:pageBlockSectionItem >
<!-- Your Checkboxes here, onchange should rerender the below section which has your Activity Date--->
<apex:inputField value="{!Newcase.Are_you_going_to_call_back__c}">
<apex:actionSupport event="onchange" reRender="DueDate" />
</apex:inputField>
</apex:pageBlockSectionItem>
<apex:pageblockSectionItem >
<apex:outputlabel value="{!$ObjectType.Case.fields.ActivityDate__c.label}"/>
<apex:outputPanel id="DueDate">
<apex:inputField value="{!NewCase.ActivityDate__c}" required="{!Newcase.Are_you_going_to_call_back__c || Newcase.Follow_up_required__c}"/>
</apex:outputPanel>
</apex:pageblockSectionItem>
Kindly mark this as the answer if you are resolved
Thanks
CodeWizard, I will try your way aswell to see if that could be an alternative way to achieve the result. Thanks Both