here is my page block table:
<apex:pageblock title="RRD Approved Start and Complete Dates">
<apex:pageblockTable value="{!scheduleEmailLinkWrapperList}" var="d">
<apex:column headerValue="Milestone Complete Dates">
<apex:outputText value="{!d.milestone}"/>
</apex:column>
<apex:column headerValue="Approved Start">
<apex:inputField value="{!d.promotion.CustomerDeliveryDate__c}"/>
</apex:column>
<apex:column headerValue=" Approved Complete">
<apex:inputField value="{!d.promotion.ProdFinishDueActualCompletePriorValue__c}"/>
</apex:column>
</apex:pageblockTable>
</apex:pageblock>
here is my wrapper class in the controller:
public class ScheduleEmailLinkWrapper {
// constructor for approval dates table
public string milestone{get;set;}
public Promotion__c promotion{get;set;}
public ScheduleEmailLinkWrapper(string milestone, Promotion__c promotion) {
this.milestone = milestone;
this.promotion=promotion;
}
}
On initialization of my controller, I am getting the promotion ID from the page parameters and querying the promotion with the ID and sending it to fill my wrapper class list. here is the code which does that:
List<string> milestoneCollection = new List<string>{'Creative','Estimating','Artwork Due','Proof Approved','Production/Finishing','Kitting','Shipping','Invoicing'};
if(ApexPages.currentPage().getParameters().get('id')!=null) {
Id promotionId = ApexPages.currentPage().getParameters().get('id');
promo = [select id,name,CustomerDeliveryDate__c,ProdFinishDueActualCompletePriorValue__c from Promotion__c where id = :promotionId];
if(promo.CustomerDeliveryDate__c!=null)
promo.CustomerDeliveryDate__c = null;
if(promo.ProdFinishDueActualCompletePriorValue__c!=null)
promo.ProdFinishDueActualCompletePriorValue__c = null;
}
scheduleEmailLinkWrapperList = new List<ScheduleEmailLinkWrapper>();
for(string milestone : milestoneCollection) {
ScheduleEmailLinkWrapper scheduleEmailLinkWrapper = new ScheduleEmailLinkWrapper(milestone, promo);
scheduleEmailLinkWrapperList.add(ScheduleEmailLinkWrapper);
}
The reason I am using the !d.promotion.CustomerDeliveryDate__c and !d.promotion.ProdFinishDueActualCompletePriorValue__c in my page as values because I just want to use the dummy dates so that I could get the calendar in my input field.
I have a calculate dates button when clicked, I have to update the invoicing row Approved Start Date. so on click of calculate button I have this:
public void calculateDates() {
for(ScheduleEmailLinkWrapper scheduleEmail : scheduleEmailLinkWrapperList) {
if(scheduleEmail.milestone=='Invoicing') {
system.debug('--here--'+scheduleEmail.milestone);
scheduleEmail.promo.CustomerDeliveryDate__c= custDeliveryDate;
}
}
}
This updates all the Approved Start Dates for all the rows rather than just the invoicing row Approved Start Date. How do I make sure it just updates the invoicing row alone??