4

I have developed a VF page form for our customer to place order through form, Here we have a option for them to selcect the First and Second reminder day and time .

Please find the apex logic:

private boolean validateWebTimesheetInformation()
{

    boolean isThisSessionValid = true;  
    try{

    order.First_email_reminder_time__c = (selectedREMFirstEmailHours==null ? '00': selectedREMFirstEmailHours) + ':' + (selectedREMFirstEmailMinutes==null? '00' : selectedREMFirstEmailHours) + ' '  + (selectedREMFirstEmailTimePeriod ==null ? 'AM/PM' : selectedREMFirstEmailTimePeriod);
    order.Second_email_reminder_time__c = (selectedREMSecondEmailHours==null ? '00': selectedREMSecondEmailHours) + ':' + (selectedREMSecondEmailMinutes==null? '00' : selectedREMSecondEmailMinutes) + ' '  + (selectedREMSecondEmailTimePeriod ==null ? 'AM/PM' : selectedREMSecondEmailTimePeriod);

    order.Submitter_First_reminder_time__c = (selectedSUBFirstEmailHours==null ? '00': selectedSUBFirstEmailHours) + ':' + (selectedSUBFirstEmailMinutes==null? '00' : selectedSUBFirstEmailHours) + ' '  + (selectedSUBFirstEmailTimePeriod ==null ? 'AM/PM' : selectedSUBFirstEmailTimePeriod);
    order.Submitter_Second_reminder_time__c = (selectedSUBSecondEmailHours==null ? '00': selectedSUBSecondEmailHours) + ':' + (selectedSUBSecondEmailMinutes==null? '00' : selectedSUBSecondEmailMinutes) + ' '  + (selectedSUBSecondEmailTimePeriod ==null ? 'AM/PM' : selectedSUBSecondEmailTimePeriod);                 

    order.PTA_First_email_Time__c = (selectedPTAFirstEmailHours==null ?'00' : selectedPTAFirstEmailHours) +':' + (selectedPTAFirstEmailMinutes==null ? '00' : selectedPTAFirstEmailMinutes) + ' ' + (selectedPTAFirstEmailTimePeriod==null ? 'AM/PM' : selectedPTAFirstEmailTimePeriod);
    order.PTA_Second_email_Time__c = (selectedPTASecondEmailHours==null ? '00' : selectedPTASecondEmailHours) +':' + (selectedPTASecondEmailMinutes==null ? '00' : selectedPTASecondEmailMinutes) + ' ' + (selectedPTASecondEmailTimePeriod==null ? 'AM/PM' : selectedPTASecondEmailTimePeriod);
    order.PTA_Escalation_email_Time__c = (selectedPTAEsclationEmailHours==null ? '00' : selectedPTAEsclationEmailHours) +':' + (selectedPTAEsclationEmailMinutes==null ? '00' : selectedPTAEsclationEmailMinutes) + ' ' + (selectedPTAEsclationEmailTimePeriod ==null ? 'AM/PM' : selectedPTAEsclationEmailTimePeriod);

Here is the associated VF page that will allow customer to enter value.:

 <apex:pageBlockSection title="When do you want associates to receive email reminders?" rendered="{!order.Type=='Web Timesheet'}" columns="1">
                <apex:actionRegion >                    
                    <table style="width:50%;">
                        <tr>
                            <td style="text-align:right;width:35%;font-weight:bold;font-size:11px;color: #4a4a56;padding-right: 2px;">First email reminder day</td>
                            <td style="padding-left: 10px;width:50px;"><apex:inputField value="{!order.First_email_reminder_day__c}"  >                                       
                                </apex:inputField>
                            </td>
                            <td style="width:55px;text-align:right;font-weight:bold;font-size:11px;color: #4a4a56;padding-right: 2px;"><apex:outputLabel value="and Time" ></apex:outputLabel> </td>
                            <td style="padding-left: 10px;">
                                <apex:selectList value="{!selectedREMFirstEmailHours}" size="1" style="width:50px">
                                    <apex:selectOptions value="{!REMFirstEmailHours}"/>                                     
                                </apex:selectList>
                                <apex:selectList value="{!selectedREMFirstEmailMinutes}" size="1" style="width:50px">
                                    <apex:selectOptions value="{!REMFirstEmailMinutes}"/>                                       
                                </apex:selectList>
                                <apex:selectList value="{!selectedREMFirstEmailTimePeriod}" size="1" style="margin-left:2px;">
                                    <apex:selectOptions value="{!REMFirstEmailTimePeriod}"/>                                        
                                </apex:selectList>                                    
                            </td>
                        </tr>
                    </table>                    
                </apex:actionRegion>       

Now below VF code is the Confirmation page's:

<apex:pageBlockSection id="Whendoyouwantassociatestoreceiveemailreminders" columns="1" rendered="{!order.Type=='Web Timesheet'}">
                <apex:outputPanel rendered="{!order.Type=='Web Timesheet'}">
                    <table style="width:50%;">
                            <tr>
                                <td style="text-align:right;width:35%;font-weight:bold;font-size:11px;color: #4a4a56;padding-right: 2px;">First email reminder day and time</td>
                                <td style="padding-left: 10px;"><apex:outputField value="{!order.First_email_reminder_day__c}"  >                                       
                                    </apex:outputField>
                                </td>
                                <td style="text-align:right;font-weight:bold;font-size:11px;color: #4a4a56;padding-right: 2px;">and Time </td>
                                <td style="padding-left: 10px;">
                                    <apex:outputText value="{!order.First_email_reminder_time__c}"/>
                                </td>
                            </tr>
                        </table>     

But , when the customer enters the time with hours ,minute and Period it is not showing up in the confirmation page, However it is showing in the preview page.

Also after inserting the the entered time is 7:00 AM but in the Order detail page in SF it is showing 7:07 AM.

Please find the image of the VF edit page: enter image description here

This page is the Preview page before submitting the form. enter image description here

This page is showing the time entered by the customer

Please find the Confirmation page after submit. enter image description here

This is the Order detail page below Here the time is showing as 7:07AM but the client entered was 7:00 AM

enter image description here

Hi this is the controller that will pull the values from the saved order to show up the values in confirmation page.

 public NewOrderSuccessController(ApexPages.StandardController controller)
{

    String OrderNumbers = GetValueFromParam('OrderNumbers'); 
    accountId = '';
    if(OrderNumbers.contains(';'))
    {
        String[] splitNumbers = OrderNumbers.split(';');
        OrderNumbers = splitNumbers[0];
        String str1 = splitNumbers[1];            

       /* if(str1.contains('CID'))
        {
            String[] splitaccount = str1.split('=');
            accountId = splitaccount[1];
        } */       
    }


    if(OrderNumbers!=null){
     OrderNumbers = OrderNumbers.replaceAll(' ', '');
         String[] splits = OrderNumbers.split(',');

        String succMes = (splits.size() >1 ? 'Thank you for your order request.  Your Order Numbers are ' : 'Thank you for your order request.  Your Order Number is ');
        newOrders = [Select id,
                     Order_Contact__c,
                     OrderNumber,
                     Order_Contact_Phone__c,
                     Order_Contact_Email__c,
                     Type,
                     Rush_Order__c,
                     Type_Of_Order__c,
                     Training_Required__c,
                     Type_Of_Clock__c,
                     Number_of_Clock_Required__c,
                     Ship_to__c,Shipping_Attention__c,
                     Shipping_Attention_Email__c,
                     Shipping_Attention_Phone__c,
                     Shipping_Street__c,
                     Suite_Floor_Address_2__c,
                     Shipping_City__c,
                     Shipping_State__c,
                     Shipping_Postal_Code__c,
                     Shipping_Country__c,
                     Clock_Location_Restriction__c,
                     IP_Restricted__c,
                     Type_of_Clock_Requested__c,
                     Connection_Type__c,
                     Static_IP_Address__c,
                     Static_Subnet_Mask__c,
                     Static_Gateway_Adress__c,
                     DNS1__c,
                     DNS2__c,
                     Branch_Name__c,
                     Branch_number__c,
                     Associates_to_enter_time__c,
                     First_email_reminder_day__c,
                     Second_email_reminder_day__c,
                     PTA_First_email_Day__c,
                     PTA_Second_email_Day__c,
                     PTA_Escalation_email_Day__c,
                     Provide_all_phone_numbers_Employees_can__c,
                     StartTime_for_the_Last_shift_week_time__c,
                     PTA_First_email_Time__c,
                     PTA_Second_email_Time__c,
                     PTA_Escalation_email_Time__c,
                     First_shift_of_the_week_s_start_time__c,
                     Associates_to_enter_late_time__c,
                     i_How_Many_Weeks__c,
                     Last_day_of_your_pay_week__c,
                     Set_up_for_Group_Timesheet__c,
                     Clients_Branch_Name__c,
                     Clients_Branch_ID__c,
                     GT_How_do_they_need_to_enter_time__c,
                     GT_First_name_of_time_submitter__c,
                     GT_Last_name_of_time_submitter__c,
                     Submitter_s_email_address__c,
                     Submitter_First_reminder_day__c,
                     Submitter_Second_reminder_day__c,
                     Auto_approved_submitted_Group_Timesheet__c,
                     Over_Time_Rules__c,
                     Submitter_First_reminder_time__c,
                     Submitter_Second_reminder_time__c,
                     Notes__c,
                     Customer_Name__c,
                     Business_Unit_Or_Accounting_number__c,
                     Site_ID_or_Branch_ID_Number__c,
                     Name_of_Clock_Location__c,
                     Site_Street_Address_1__c,
                     Site_Street_Address_2__c,
                     Site_City__c,
                     Site_State__c,
                     Site_ZIP__c,
                     Site_Country_if_not_USA__c,
                     Site_TimeZone__c,
                     Number_of_Employees__c,
                     Pay_Period__c,
                     First_Day_of_payroll_Week__c,
                     First_shift_of_the_week_s_start_day__c,
                     StartTime_for_the_Last_shift_of_the_week__c,
                     Third_Shift_employee_at_the_site__c,
                     OverTime_Rules__c,
                     State_OT_Rules__c,
                     Daily_OT_after_How_many_hours__c,
                     Weekly_OT_after_how_many_hours__c,
                     Second_email_reminder_time__c,
                     First_email_reminder_time__c,
                     Does_the_7th_day_rule_apply__c,
                     Non_Standard_Notes__c,
                     Time_Tracking_Options__c,
                     Grace_Period_Before_Shift__c,
                     Grace_Period_After_Shift__c,
                     Meal_Break__c,
                     Length_of_the_meal_break__c,
                     Min_hours_worked_for_auto_meal_deduction__c,
                     California_Meal_Prompts__c,
                     Are_Departments_sent_in_Integration_file__c,
                     Special_Pay_Policies_or_Requests__c,(Select id, Name__c,OEmail__c,Phone__c,OrderId__c from OrderTrainings__r),
                     (Select Department_Number__c,Department_Code__c,Department_Name__c from TTDepartments__r),
                     (Select IPR_RequestIP_Address__c from IPAddresss__r),
                     (Select End_Hours__c,End_Mins__c,End_Time_Period__c,Shift_Name__c,Start_Hours__c,Start_Mins__c,Start_Time_Period__c from SoftSchedulingShifts__r),
                     (Select Client_ID__c,Client_Name__c from GroupTimeSheet_Clients__r)
                     from Order where OrderNumber IN :splits]; 
2

For the first error with the wrong time, you set the minutes using the hours variable. Here's the right code:

order.First_email_reminder_time__c = (selectedREMFirstEmailHours==null ? '00': selectedREMFirstEmailHours) + ':' + (selectedREMFirstEmailMinutes==null? '00' : selectedREMFirstEmailMinutes) + ' '  + (selectedREMFirstEmailTimePeriod ==null ? 'AM/PM' : selectedREMFirstEmailTimePeriod);

order.Submitter_First_reminder_time__c = (selectedSUBFirstEmailHours==null ? '00': selectedSUBFirstEmailHours) + ':' + (selectedSUBFirstEmailMinutes==null? '00' : selectedSUBFirstEmailMinutes) + ' '  + (selectedSUBFirstEmailTimePeriod ==null ? 'AM/PM' : selectedSUBFirstEmailTimePeriod);

Edit after a tchat with Samuel: The second error was due to the public access setting not checked.

7
  • Hi martin, the above code you have added in your answer is same as the code I have in my question – Samuel Robert Jan 10 '17 at 14:59
  • Hi Samuel. No it's not. You are using this variable for the minutes: selectedREMFirstEmailHours instead of this variable: selectedREMFirstEmailMinutes – Martin Lezer Jan 10 '17 at 15:00
  • Hi martin yes , Now I saw, actually my question was edited and changed thats y iam confused thanks for that. I also added the apex controller logic for the confirmation page in my question. – Samuel Robert Jan 10 '17 at 15:05
  • Samuel, I don't see the Order variable in your controller. The variable that you use in your VF page. – Martin Lezer Jan 10 '17 at 15:08
  • Ok I think this is the issue, I suppose to use newOrders.First_email_reminder_time__c , but i get unknown property error since it is declared as List. – Samuel Robert Jan 10 '17 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.