• FL blondie
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
My first attempt at coding and just can't make it work.  All I need is to pull records for a particular day, from a preload table and update the volume counts.  When I click on save or enter the date it creates a new record.  How  can I fix this?  

Here is the code:

public class RescueCountExtension {

    private final Rescue_count__c acct;

    public RescueCountExtension(ApexPages.StandardController stdController) {
        this.acct = (Rescue_count__c)stdController.getRecord();
 
   }
public Date SelectedDate {get;set;}

List<Rescue_Count__c> theDaysRecords;

Public List<Rescue_Count__c> getTheDaysRecords(){
   if(theDaysRecords == null){
      theDaysRecords = [SELECT Donor__c, Rescue_Date__c, BR__C, BU__c, BA__c, TA__c, BA_Bulk__C, TA_Bulk__C,Produce__c, Meat_Deli__c, Shelf_Stable__c, Non_Food__c from Rescue_count__c Order by Donor__c ];
}
return theDaysRecords;   
       
    }
}


//THE PAGE:
<apex:page standardController="Rescue_Count__c" extensions="RescueCountExtension" sidebar="false">

  
<apex:sectionheader title="Mass Edit Rescue Counts" />
<apex:form >

<apex:pageBlock title="Rescue Counts" rendered="true" mode="edit" >
<apex:pageMessages />

Note: All modifications made on the page will be lost if Return button is clicked without clicking the Save button first.

<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>     

<apex:pageBlockSection title="Records to Update"
collapsible="false">
<apex:outputLabel value="Select Date"/>

<apex:inputText value="{!SelectedDate}" size="10" id="queryDate" onfocus="DatePicker.pickDate(false, this, false);" />
  <apex:actionSupport event="onchange" rerender="thetable"/>

</apex:pageBlockSection>

<apex:pageBlockTable value="{!theDaysRecords}" var="a" id="thetable">
<apex:column headerValue="Donor">
<apex:outputField value="{!a.Donor__c}"/>
</apex:column>
<apex:column headerValue="Date">
<apex:outputField value="{!a.Rescue_Date__c}"/>
</apex:column>
<apex:column headerValue="BR">
<apex:inputField value="{!a.BR__c}"/>
</apex:column>
<apex:column headerValue="BU">
<apex:inputField value="{!a.BU__c}"/>
</apex:column>
<apex:column headerValue="BA">
<apex:inputField value="{!a.BA__c}"/>
</apex:column>
<apex:column headerValue="TA">
<apex:inputField value="{!a.TA__c}"/>
</apex:column>
<apex:column headerValue="BA_Bulk">
<apex:inputField value="{!a.BA_Bulk__c}"/>
</apex:column>
<apex:column headerValue="TA_Bulk">
<apex:inputField value="{!a.TA_Bulk__c}"/>
</apex:column>
<apex:column headerValue="Produce">
<apex:inputField value="{!a.Produce__c}"/>
</apex:column>
<apex:column headerValue="Meat/Deli">
<apex:inputField value="{!a.Meat_Deli__c}"/>
</apex:column>
<apex:column headerValue="Shelf Stable">
<apex:inputField value="{!a.Shelf_Stable__c}"/>
</apex:column>
<apex:column headerValue="Non_Food">
<apex:inputField value="{!a.Non_Food__c}"/>
</apex:column>
</apex:pageBlockTable>

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

Our non-profit needs the ability to print a report, by day, listing all the jobs worked that day.  The end user will use this report to log the donations that each job received.  

 

We have a custom object that stores the job title and work date for all the jobs performed.  I have the visualforce page written and it correctly prints to pdf.  Now how do I create an input form to get the date range for the reports and then print the report, one page for each day?

My first attempt at coding and just can't make it work.  All I need is to pull records for a particular day, from a preload table and update the volume counts.  When I click on save or enter the date it creates a new record.  How  can I fix this?  

Here is the code:

public class RescueCountExtension {

    private final Rescue_count__c acct;

    public RescueCountExtension(ApexPages.StandardController stdController) {
        this.acct = (Rescue_count__c)stdController.getRecord();
 
   }
public Date SelectedDate {get;set;}

List<Rescue_Count__c> theDaysRecords;

Public List<Rescue_Count__c> getTheDaysRecords(){
   if(theDaysRecords == null){
      theDaysRecords = [SELECT Donor__c, Rescue_Date__c, BR__C, BU__c, BA__c, TA__c, BA_Bulk__C, TA_Bulk__C,Produce__c, Meat_Deli__c, Shelf_Stable__c, Non_Food__c from Rescue_count__c Order by Donor__c ];
}
return theDaysRecords;   
       
    }
}


//THE PAGE:
<apex:page standardController="Rescue_Count__c" extensions="RescueCountExtension" sidebar="false">

  
<apex:sectionheader title="Mass Edit Rescue Counts" />
<apex:form >

<apex:pageBlock title="Rescue Counts" rendered="true" mode="edit" >
<apex:pageMessages />

Note: All modifications made on the page will be lost if Return button is clicked without clicking the Save button first.

<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>     

<apex:pageBlockSection title="Records to Update"
collapsible="false">
<apex:outputLabel value="Select Date"/>

<apex:inputText value="{!SelectedDate}" size="10" id="queryDate" onfocus="DatePicker.pickDate(false, this, false);" />
  <apex:actionSupport event="onchange" rerender="thetable"/>

</apex:pageBlockSection>

<apex:pageBlockTable value="{!theDaysRecords}" var="a" id="thetable">
<apex:column headerValue="Donor">
<apex:outputField value="{!a.Donor__c}"/>
</apex:column>
<apex:column headerValue="Date">
<apex:outputField value="{!a.Rescue_Date__c}"/>
</apex:column>
<apex:column headerValue="BR">
<apex:inputField value="{!a.BR__c}"/>
</apex:column>
<apex:column headerValue="BU">
<apex:inputField value="{!a.BU__c}"/>
</apex:column>
<apex:column headerValue="BA">
<apex:inputField value="{!a.BA__c}"/>
</apex:column>
<apex:column headerValue="TA">
<apex:inputField value="{!a.TA__c}"/>
</apex:column>
<apex:column headerValue="BA_Bulk">
<apex:inputField value="{!a.BA_Bulk__c}"/>
</apex:column>
<apex:column headerValue="TA_Bulk">
<apex:inputField value="{!a.TA_Bulk__c}"/>
</apex:column>
<apex:column headerValue="Produce">
<apex:inputField value="{!a.Produce__c}"/>
</apex:column>
<apex:column headerValue="Meat/Deli">
<apex:inputField value="{!a.Meat_Deli__c}"/>
</apex:column>
<apex:column headerValue="Shelf Stable">
<apex:inputField value="{!a.Shelf_Stable__c}"/>
</apex:column>
<apex:column headerValue="Non_Food">
<apex:inputField value="{!a.Non_Food__c}"/>
</apex:column>
</apex:pageBlockTable>

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

Apologies if this has already been answered but I have spent more than an hour looking and still cannot find an answer to my problem:

 

I am using a datepicker on an apex:inputtext field, to establish a from and to date range. It works fine, but when the screen is refreshed the value in the date changes from:

 

   D/MM/YYY format (what I am after), to something like this: 

   Mon Jul 15 00:00:00 GMT 2013

 

Therefore, next time I attempt to perform an action, I get an error message saying:

 

   Error:   Value 'Mon Jul 15 00:00:00 GMT 2013' cannot be converted from Text to Date
 
How can I prevent the date from being incorrectly reformatted?
 
Here is an exceprt from my VF code:
 

<apex:pageBlockSectionItem >
   <apex:outputLabel value="From Due Date" for="fromDate"/>
   <apex:inputText value="{!fromDateCriteria}" size="10" onfocus="DatePicker.pickDate(false, this, false);" id="fromDate" />
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >

 

<apex:pageBlockSectionItem >
   <apex:outputLabel value="To Due Date" for="toDate"/>
   <apex:inputText value="{!toDateCriteria}" size="10" onfocus="DatePicker.pickDate(false, this, false);" id="toDate" />
</apex:pageBlockSectionItem>

 

 

My controller simply uses auto getters and setters:

 

public date FromDateCriteria {get;set;}
public date ToDateCriteria {get;set;}

 

Everything work fine, except for the reformat when the UI is redisplayed.

 

Thanks in advance...