You need to sign in to do that
Don't have an account?
Kiyana Dunlock
Trying to create simple vf page with date inputs that are passed back to the controller and used in the SOQL
Hi Team!!
Currently the first SOQL is working but when I update the dates and click submit I still see the same list of schedules even though they are not in the range. Was trying to get the start week working in my code first but I need both start and end.
VF Page
Controller
I know I need an action with the Submit but Im not sure how to set it up. I tries this and recieved numerous erros:
Currently the first SOQL is working but when I update the dates and click submit I still see the same list of schedules even though they are not in the range. Was trying to get the start week working in my code first but I need both start and end.
VF Page
<apex:page standardController="Schedules__c" extensions="WeeklyComparisonController"> <script> function toggleContacts(className){ elem = document.getElementsByClassName(className)[0]; if(elem.style.display == 'none') elem.style.display = 'block'; else elem.style.display = 'none'; } </script> <apex:form > <apex:panelGrid columns="5" id="dates1"> <b>Start Date: </b><apex:inputfield value="{!firstRangeWeek.Week__c}"/> <b>End Date: </b><apex:inputfield value="{!Schedules__c.Week__c}"/> <apex:commandButton value="Submit" rerender="dates1, case"/> </apex:panelGrid> <apex:outputPanel id="test"> <apex:repeat value="{!sched}" var="s" id="scheds"> <apex:pageBlock title="{!s.Name} {!s.Week__c} ({!s.ID})"> Data </apex:pageBlock> </apex:repeat> </apex:outputPanel> </apex:form> </apex:page>
Controller
public class WeeklyComparisonController { public Schedules__c firstRangeWeek{get; set;} public WeeklyComparisonController(ApexPages.StandardController sc){ firstRangeWeek = new Schedules__c(Week__c = date.today().toStartofWeek().AddDays(-6)); } public Schedules__c[] sched { get { return [ SELECT Id, Name, Week__c FROM Schedules__c WHERE DealProgram__c = 'ION Television' AND Week__c >= :date.valueOf(firstRangeWeek.Week__c) ]; } } }
I know I need an action with the Submit but Im not sure how to set it up. I tries this and recieved numerous erros:
The Errors which you are receiving is you did not Initiase sched in the second method. You only created that variable in First method . So in second method you need to query as below.
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,