• Task
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 4
    Replies

public with sharing class RenderController
{
  public RFQ__C rfq {get; set;}
  public boolean privatefleet {get; set;}
  public boolean Dryvan{get; set;}
  public boolean Flatbed{get; set;}
  public boolean Reefer{get; set;}
  public boolean IMDL{get; set;}
  public boolean LTL{get; set;}
  public boolean RFI{get; set;}
  public Bid__C bid {get; set;}

  public RenderController(ApexPages.StandardController controller)
    {
      String rfqid = Apexpages.Currentpage().getparameters().get('rfqid');
      if(rfqid !=null)
      {
         bid = [select name,Modes__c,RFQ__c,f_RFQ_Due_Date__c,Lanes__c,RFQ_Status__c,Expected_LPD__c,Bid_Status__c,Bid_Stage__c,FSC_Type__c,
                FSC_Peg__c,LPD_Goal__c,Total_LPD__c,Send_to_Pricing_Team__c,Notes__c from Bid__c limit 1];
      }
      else
      {
         bid = new Bid__c();
      }
    }
  public RenderController()
  {    
     rfq = new RFQ__C();
     String rfqid = Apexpages.Currentpage().getparameters().get('rfqid');
     rfq = [select Mode_s__c from RFQ__c where id=:rfqid limit 1]; //30th line - Error is in this line
     
     if(rfq.Mode_s__c.contains('Private Fleet'))
     {
       privatefleet = true;
       bid = [select Will_Load_Following_Trailers__c,Days_of_Week__c,Must_be_food_grade_trailer__c,Driver_Work__c,Lead_Time__c,Shipper_Hours_To__c,Shipper_Hours_From__c,Cons_Hours_To__c,Cons_Hours_From__c from Bid__C where Modes__C = 'Private Fleet'];
     }

     if(rfq.Mode_s__c.contains('Dry Van'))
     {      
     }

     if(rfq.Mode_s__c.contains('Flatbed'))
     {
      Flatbed = true;
      bid = [select Ready_at__c,Securing_Accessories__C,Deliver_by__c,Level_of_flexibility__c,Are_moves_Over_Dimensional__c,Dimensions__c,Well_Space_Needed_or_Floor_Space__c,Tarps__c,Products_Overhang_on_Front_or_Rear__c from Bid__C where Modes__C = 'Flatbed'];
     }

      if(rfq.Mode_s__c.contains('Reefer'))
     {
      Reefer= true;
      bid = [select Temp_Low_del__c,Temp_High_del__C from Bid__C where Modes__C = 'Reefer'];
     }

      if(rfq.Mode_s__c.contains('IMDL'))
     {
      IMDL= true;
      bid = [select Container_Size__c,f_IMDL_Opportunity_Type__C,f_Shipment_Types__c,f_Current_IMDL_provider_types__c,f_Incumbent_IMDL_Providers__c,f_Other_IMDL_providers_notes__c from Bid__C where Modes__C = 'IMDL'];
     }

      if(rfq.Mode_s__c.contains('LTL'))
     {
      LTL= true;
      bid = [select LTL_Class__c,Class_Distribution_Notes__C,FAK_Applicable__c,FAK_Notes__c,Tariff_Base_Year__c,FSC_Schedule__c from Bid__C where Modes__C = 'LTL'];
     }

      if(rfq.Mode_s__c.contains('RFI'))
     {
       RFI= true;
       bid = [select RFI_Required__c,RFI_Status__C,RFI_Dependent__c,RFI_Due_Date__c from Bid__C where Modes__C = 'RFI'];
     }
  }
  public pagereference save()
  {
   upsert bid;
   Pagereference pg = new Pagereference('/a0B/o');
   return pg;
  }
  public PageReference Cancel()
  {
    Pagereference pg = new Pagereference('/a01/o');
    return pg;
  }
  }

  • May 22, 2013
  • Like
  • 0

I receieve the following error with this Apex Controller

System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Bid__c.Name

Apex Controller:

public with sharing class RenderController
{
  public RFQ__C rfq {get; set;}
  public boolean privatefleet {get; set;}
  public boolean Dryvan{get; set;}
  public boolean Flatbed{get; set;}
  public boolean Reefer{get; set;}
  public boolean IMDL{get; set;}
  public boolean LTL{get; set;}
  public boolean RFI{get; set;}
  public Bid__c bid{get;set;}

  public RenderController()
  {
     rfq  = new  RFQ__C();
     String rfqid = Apexpages.Currentpage().getparameters().get('rfqid');
     rfq = [select name,f_Account_Owner__c,Account_Owner__c,Mode_s__c from RFQ__c where id=:rfqid];

     if(rfq.Mode_s__c.contains('Private Fleet'))
     {
       privatefleet = true;
       bid = [select Will_Load_Following_Trailers__c,Days_of_Week__c,Must_be_food_grade_trailer__c,Driver_Work__c,Lead_Time__c,Shipper_Hours_To__c,Shipper_Hours_From__c,Cons_Hours_To__c,Cons_Hours_From__c from Bid__C where RFQ__C=:rfqid and Modes__C = 'Private Fleet'];
     }

     if(rfq.Mode_s__c.contains('Dry Van'))
     {      
     }

     if(rfq.Mode_s__c.contains('Flatbed'))
     {
      Flatbed = true;
      bid = [select Ready_at__c,Securing_Accessories__C,Deliver_by__c,Level_of_flexibility__c,Are_moves_Over_Dimensional__c,Dimensions__c,Well_Space_Needed_or_Floor_Space__c,Tarps__c,Products_Overhang_on_Front_or_Rear__c from Bid__C where RFQ__C=:rfqid and Modes__C = 'Flatbed'];
     }

      if(rfq.Mode_s__c.contains('Reefer'))
     {
      Reefer= true;
      bid = [select Temp_Low_del__c,Temp_High_del__C from Bid__C where RFQ__C=:rfqid and Modes__C = 'Reefer'];
     }

      if(rfq.Mode_s__c.contains('IMDL'))
     {
      IMDL= true;
      bid = [select Container_Size__c,f_IMDL_Opportunity_Type__C,f_Shipment_Types__c,f_Current_IMDL_provider_types__c,f_Incumbent_IMDL_Providers__c,f_Other_IMDL_providers_notes__c from Bid__C where RFQ__C=:rfqid and Modes__C = 'IMDL'];
     }

      if(rfq.Mode_s__c.contains('LTL'))
     {
      LTL= true;
      bid = [select LTL_Class__c,Class_Distribution_Notes__C,FAK_Applicable__c,FAK_Notes__c,Tariff_Base_Year__c,FSC_Schedule__c from Bid__C where RFQ__C=:rfqid and Modes__C = 'LTL'];
     }

      if(rfq.Mode_s__c.contains('RFI'))
     {
       RFI= true;
       bid = [select RFI_Required__c,RFI_Status__C,RFI_Dependent__c,RFI_Due_Date__c from Bid__C where RFQ__C=:rfqid and Modes__C = 'RFI'];
     }
  }
  public pagereference save()
  {
   upsert bid;
   Pagereference pg = new Pagereference('/a0B/o');
   return pg;
  }
  public PageReference Cancel()
  {
    Pagereference pg = new Pagereference('/a01/o');
    return pg;
  }
 VF page:

<apex:page controller="RenderController" tabStyle="RFQ__c">
   <apex:form >
       <apex:sectionHeader title="RFQ Edit" subtitle="New RFQ"/>
       <apex:pageBlock id="rfqmain" title="RFQ Information" mode="Edit">
        <apex:pageBlockButtons >
         <apex:commandButton value="Save" action="{!save}"/>
         <apex:commandButton value="Cancel" action="{!Cancel}"/>
          </apex:pageBlockButtons>
          <apex:pageBlockSection title="RFQ Information">
            <apex:outputField value="{!rfq.name}"/>
            <apex:outputField value="{!rfq.f_Account_Owner__c}"/>
            <apex:outputField value="{!rfq.Account_Owner__c}"/>
            <apex:outputField value="{!rfq.Mode_s__c}"/>
          </apex:pageBlockSection>
          <apex:pageBlockSection title="Information">
             <apex:outputField value="{!bid.name}"/>
             <apex:outputField value="{!bid.Modes__c}"/>
             <apex:outputField value="{!bid.RFQ__c}"/>
             <apex:outputField value="{!bid.f_RFQ_Due_Date__c}"/>
             <apex:outputField value="{!bid.Lanes__c}"/>
             <apex:outputField value="{!bid.RFQ_Status__c}"/>
             <apex:outputField value="{!bid.Expected_LPD__c}"/>
             <apex:outputField value="{!bid.Bid_Status__c}"/>
             <apex:outputField value="{!bid.Bid_Stage__c}"/>
             <apex:outputField value="{!bid.FSC_Type__c}"/>
             <apex:outputField value="{!bid.FSC_Peg__c}"/>
             <apex:outputField value="{!bid.LPD_Goal__c}"/>
             <apex:outputField value="{!bid.Total_LPD__c}"/>   
             <apex:outputField value="{!bid.Send_to_Pricing_Team__c}"/>                                                                                                     
          </apex:pageBlockSection>
           <apex:pageBlockSection title="Notes">
             <apex:outputField value="{!bid.Notes__c}"/>
           </apex:pageBlockSection>         
             <apex:pageBlockSection title="private fleet" id="Privatefleet" rendered="{!Privatefleet}">
             <apex:inputField value="{!bid.Will_Load_Following_Trailers__c}"/>
             <apex:inputField value="{!bid.Days_of_Week__c}"/>
             <apex:inputField value="{!bid.Must_be_food_grade_trailer__c}"/>
             <apex:inputField value="{!bid.Driver_Work__c}"/>
             <apex:inputField value="{!bid.Lead_Time__c}"/>
             <apex:inputField value="{!bid.Shipper_Hours_To__c}"/>
             <apex:inputField value="{!bid.Shipper_Hours_From__c}"/>
             <apex:inputField value="{!bid.Cons_Hours_To__c}"/>
             <apex:inputField value="{!bid.Cons_Hours_From__c}"/>
           </apex:pageBlockSection>
           
           <apex:pageBlockSection title="Dry Van" id="Dryvan" rendered="{!Dryvan}">
           </apex:pageBlockSection>
                        
           <apex:pageBlockSection title="Flatbed" id="Flatbed" rendered="{!Flatbed}">
             <apex:inputField value="{!bid.Ready_at__c}"/>
             <apex:inputField value="{!bid.Securing_Accessories__c}"/>
             <apex:inputField value="{!bid.Deliver_by__c}"/>
             <apex:inputField value="{!bid.Level_of_flexibility__c}"/>
             <apex:inputField value="{!bid.Are_moves_Over_Dimensional__c}"/>
             <apex:inputField value="{!bid.Dimensions__c}"/>
             <apex:inputField value="{!bid.Well_Space_Needed_or_Floor_Space__c}"/>
             <apex:inputField value="{!bid.Tarps__c}"/>
             <apex:inputField value="{!bid.Products_Overhang_on_Front_or_Rear__c}"/>
           </apex:pageBlockSection>   
           
           <apex:pageBlockSection title="Reefer Requirements" id="Reefer" rendered="{!Reefer}">
             <apex:inputField value="{!bid.Temp_Low_del__c}"/>
             <apex:inputField value="{!bid.Temp_High_del__c}"/>
           </apex:pageBlockSection>  
           
           <apex:pageBlockSection title="Intermodal" id="IMDL" rendered="{!IMDL}">
             <apex:inputField value="{!bid.Container_Size__c}"/>
             <apex:inputField value="{!bid.f_IMDL_Opportunity_Type__c}"/>
             <apex:inputField value="{!bid.f_Shipment_Types__c}"/>
             <apex:inputField value="{!bid.f_Current_IMDL_provider_types__c}"/>
             <apex:inputField value="{!bid.f_Incumbent_IMDL_Providers__c}"/>
             <apex:inputField value="{!bid.f_Other_IMDL_providers_notes__c}"/>
           </apex:pageBlockSection>  

           <apex:pageBlockSection title="LTL" id="LTL" rendered="{!LTL}">
             <apex:inputField value="{!bid.LTL_Class__c}"/>
             <apex:inputField value="{!bid.Class_Distribution_Notes__c}"/>
             <apex:inputField value="{!bid.FAK_Applicable__c}"/>
             <apex:inputField value="{!bid.FAK_Notes__c}"/>
             <apex:inputField value="{!bid.Tariff_Base_Year__c}"/>
             <apex:inputField value="{!bid.FSC_Schedule__c}"/>
           </apex:pageBlockSection>
           
           <apex:pageBlockSection title="RFI" id="RFI" rendered="{!RFI}">
             <apex:inputField value="{!bid.RFI_Required__c}"/>
             <apex:inputField value="{!bid.RFI_Status__c}"/>
             <apex:inputField value="{!bid.RFI_Dependent__c}"/>
             <apex:inputField value="{!bid.RFI_Due_Date__c}"/>
           </apex:pageBlockSection>
           
           <apex:pageBlockSection title="System Information">
            <apex:outputField value="{!bid.CreatedBy}"/>
            <apex:outputField value="{!bid.LastModifiedBy}"/>
           </apex:pageBlockSection>
          
       </apex:pageBlock>
     </apex:form>
   </apex:page>

  • May 22, 2013
  • Like
  • 0

Bid__c Object record values does not getting updated when I exectute this trigger. But I didn't receive any error in this trigger. The Bid__c object values alone not getting updated

 

trigger UpdateRFQBid on RFQ__c (after update)
{
  List<Bid__c> lstBid = new List<Bid__c>();
   for(RFQ__c r : Trigger.new)
  {
   if(r.Mode_s__c != null)
    {
      // split out the multi-select picklist using the semicolon delimiter
     for(String modes: r.Mode_s__c.split(';'))
    {
        if (modes == 'Private Fleet' && r.Bid_Private_Fleet__c == true)
        {
          // Check for EXISTING Record:
          Bid__c[] Old_Bid =
          [ SELECT Id FROM Bid__c WHERE Modes__c='Private Fleet' AND RFQ__c=:r.id];
          System.debug('Old_Bid.Size()=' + Old_Bid.Size());
          if(Old_Bid.Size()==0) // If NONE then Add
          {
             {
                Bid__c b               = new Bid__c();
                b.RFQ__C               = r.id;
                b.RecordTypeId         = '012Z00000004XEsIAM';
                b.Modes__c             = 'Private Fleet';
                b.Apex_trigger__c      = true;
                lstBid.add(b);
             }
          }     
         }
       
       {
        if (modes == 'Dry Van')
        {
         // Check for EXISTING Record:
          Bid__c[] Old_Bid =
          [ SELECT Id FROM Bid__c WHERE Modes__c='Dry Van' AND RFQ__c=:r.id];
          System.debug('Old_Bid.Size()=' + Old_Bid.Size());
          if(Old_Bid.Size()==0) // If NONE then Add
         {
            Bid__c b               = new Bid__c();
            b.RFQ__C               = r.id;
            b.RecordTypeId         = '012Z00000004XExIAM';
            b.Modes__c             = 'Dry Van';
            b.Apex_trigger__c      = true;
            lstBid.add(b);
          }
        }
       }
       
       {
          if (modes == 'Flatbed')
        {
          // Check for EXISTING Record:
           system.debug('&&&&&&');
          Bid__c[] Old_Bid =
          [ SELECT Id FROM Bid__c WHERE Modes__c='Flatbed' AND RFQ__c=:r.id];
          System.debug('Old_Bid.Size()=' + Old_Bid.Size());
          if(Old_Bid.Size()==0) // If NONE then Add
          {
            Bid__c b               = new Bid__c();
            b.RFQ__C               = r.id;
            b.RecordTypeId         = '012Z00000004XFqIAM';
            b.Modes__c             = 'Flatbed';
            b.Apex_trigger__c      = true;
            lstBid.add(b);
          }
          }
       }
       
       {
          if (modes == 'IMDL')
        {
          // Check for EXISTING Record:
          Bid__c[] Old_Bid =
          [ SELECT Id FROM Bid__c WHERE Modes__c='IMDL' AND RFQ__c=:r.id];
          System.debug('Old_Bid.Size()=' + Old_Bid.Size());
          if(Old_Bid.Size()==0) // If NONE then Add
          {
            Bid__c b               = new Bid__c();
            b.RFQ__C               = r.id;
            b.RecordTypeId         = '012Z00000004XG5IAM';
            b.Modes__c             = 'IMDL';
            b.Apex_trigger__c      = true;
            lstBid.add(b);
          }
          }
       }
       
       {
         if (modes == 'LTL')
        {
          // Check for EXISTING Record:
          Bid__c[] Old_Bid =
          [ SELECT Id FROM Bid__c WHERE Modes__c='LTL' AND RFQ__c=:r.id];
          System.debug('Old_Bid.Size()=' + Old_Bid.Size());
          if(Old_Bid.Size()==0) // If NONE then Add
          {
            Bid__c b               = new Bid__c();
            b.RFQ__C               = r.id;
            b.RecordTypeId         = '012Z00000004XG0IAM';
            b.Modes__c             = 'LTL';
            b.Apex_trigger__c      = true;
            lstBid.add(b);
          }
        }
        }
        
       {
         if (modes == 'Reefer')
        {
          // Check for EXISTING Record:
          Bid__c[] Old_Bid =
          [ SELECT Id FROM Bid__c WHERE Modes__c='Reefer' AND RFQ__c=:r.id];
          System.debug('Old_Bid.Size()=' + Old_Bid.Size());
          if(Old_Bid.Size()==0) // If NONE then Add
          {
            Bid__c b               = new Bid__c();
            b.RFQ__C               = r.id;
            b.RecordTypeId         = '012Z00000004XFlIAM';
            b.Modes__c             = 'Reefer';
            b.Apex_trigger__c      = true;
            lstBid.add(b);
          }
        }
        }
       
      {
         if (modes == 'RFI')
        {
          // Check for EXISTING Record:
          Bid__c[] Old_Bid =
          [ SELECT Id FROM Bid__c WHERE Modes__c='RFI' AND RFQ__c=:r.id];
          System.debug('Old_Bid.Size()=' + Old_Bid.Size());
          if(Old_Bid.Size()==0) // If NONE then Add
          {
            Bid__c b               = new Bid__c();
            b.RFQ__C               = r.id;
            b.RecordTypeId         = '012Z00000004XFvIAM';
            b.Modes__c             = 'RFI';
            b.Apex_trigger__c      = true;
            lstBid.add(b);
          }
        }
      }
     }
   }
    }
   upsert lstBid;
 }

  • May 20, 2013
  • Like
  • 0

My Apex class:

public with sharing class LogACallForCollections
{
    public static final String PTP_STATUS_NAME = 'PTP - Promise to pay';
    public static final String PROMISE_STATUS_MADE = 'Made';
    public static final String PROMISE_STATUS_KEPT = 'Kept';
    public static final String PROMISE_STATUS_BROKEN = 'Broken';
    public static final String DEFAULT_USER_TYPE = 'collections';

    private Task activity;   
    private Loan__c loan;
    private PageReference acctPage;
    private PageReference requestPage;
    
    public Boolean required { get; set; }
    public Task task {get;set;}

    public LogACallForCollections(ApexPages.StandardController controller)
    {   
        List<Task> a = new List<Task>();
        if (controller != null)
        {
            task = (Task)controller.getRecord();
            a = [SELECT Id,
                               PTP_Date__c,
                               PTP_Time__c,
                               Promise_Status__c,
                               User_Type__c,
                               Hold_Date__c,
                               Hold_Time__c,
                               WhatId,
                               Action_Taken__c,
                               Call_Results__c,
                               PTP_Amount__c,
                               PTP_Method__c,
                               Source_of_Funds__c,
                               Description   
                        FROM Task WHERE id = :task.Id];
            loan = getLoanById(activity.WhatId);
        }
    }

    public LogACallForCollections()
    {
    }
   
    public void change()
    {
        if (activity.Call_Results__c == PTP_STATUS_NAME)
        {
            required = false;
        }
        else
        {
            required = true;        
        }
    }

    private Loan__c getLoanById(Id loanId) {
        Loan__c[] loans = [SELECT Id,
                                  Name,
                                  Loan_WV_Number__c,
                                  Total_to_Current__c,
                                  Customer_Home_Phone__c,
                                  Customer_Name__c,
                                  Customer_Cell_Phone__c,
                                  Joint_Customer_Full_Name__c,
                                  Joint_Customer_Phone__c
                           FROM Loan__c
                           WHERE id = :loanId];
        if (loans.size() > 0)
        {
            return loans.get(0);
        }                                     
        return null;
    }

    public Loan__c getLoan()
    {
        if (loan == null)
        {
            loan = getLoanById(ApexPages.currentPage().getParameters().get('id'));   
        }
        return loan;
    }
    
    public Integer getPtpTime()
    {
        if (activity != null)
        {
            return activity.PTP_Time__c.hour();        
        }
        return 0;
    }
    
    public void setPtpTime(Integer hour)
    {
        if (activity != null)
        {
            activity.PTP_Time__c = makePtpTime(hour);
        }   
    }
    
    public Integer getHoldTime()
    {
        if (activity != null)
        {
            if (activity.Hold_Time__c == null)
                return -1;
            else
                return activity.Hold_Time__c.hourGmt();    
        }
        return -1;
    }
    
    public void setHoldTime(Integer value)
    {
        if (activity != null)
        {
            if ( value == -1 )
                activity.Hold_Time__c = null;
            else
                activity.Hold_Time__c = Datetime.newInstanceGmt(1999, 1, 1, value, 0, 0);
        }   
    }  

    private DateTime makePtpTime(Integer hour)
    {
        return DateTime.newInstance(1999, 1, 1, hour, 0, 0);
    }

    public Task getActivity()
    {
        if (activity == null)
        {
            activity = new Task();
            activity.PTP_Date__c = System.today().addDays(1);
            activity.PTP_Time__c = makePtpTime(DateTime.now().hour());
            activity.Promise_Status__c = PROMISE_STATUS_MADE;
            activity.User_Type__c = DEFAULT_USER_TYPE;
            activity.Hold_Date__c = System.today().addDays(1);
            activity.Hold_Time__c = null;
        }
        return activity;
    }

    private Boolean checkPTPAmount()
    {
        if (activity.PTP_Amount__c == null || loan.Total_to_Current__c == null)
        {
            return false;
        }
        if ((activity.PTP_Amount__c > (loan.Total_to_Current__c * 0.51) || activity.PTP_Amount__c == 50.0) &&
             activity.PTP_Amount__c <= loan.Total_to_Current__c)
             {
                return true;
             }
        return false;
    }

    private Boolean checkPTPDate()
    {
        Date dt = System.today();
        dt.daysBetween(activity.PTP_Date__c);
        return (dt.daysBetween(activity.PTP_Date__c) < 0 || dt.daysBetween(activity.PTP_Date__c) >= 31);
    }

    private static DateTime makePromiseDate(Task task)
    {
        Date currDate = task.PTP_Date__c;
        Time currTime = task.PTP_Time__c.time();
        return DateTime.newInstance(currDate, currTime);
    }

    private Boolean checkTotalToCurrentAmount()
    {
        if (loan.Total_to_Current__c == null || loan.Total_to_Current__c == 0)
        {
            return true;
        }
        return false;
    }
    
  public PageReference Submit()
  {
      Boolean ptpF = PTP_STATUS_NAME.equals(activity.Call_Results__c);
      checkTotalToCurrentAmount();

//    System.debug('ptpF: ' + ptpF + ' && ' + 'checkTotalToCurrentAmount(): ' + checkTotalToCurrentAmount() );
    if (ptpF && checkTotalToCurrentAmount())
    {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'The Loan`s Total-to-current is 0.'));
        return acctPage;
    }
    checkPTPAmount();
    checkPTPDate();
//    System.debug('!ptpF: ' + !ptpF + '  ||  ( ptpF: ' + ptpF + ' && ' + 'checkPTPAmount(): ' + checkPTPAmount() + ')');
//    System.debug('if ( ptpF: ' + ptpF + ' && checkPTPDate(): ' + checkPTPDate());
    if (!ptpF || (ptpF && checkPTPAmount()))
    {
        if (ptpF && checkPTPDate())
        {
          ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'PTP Date can be for no more than 31 calendar days in the future.'));
          return acctPage;
        }

      activity.OwnerID = UserInfo.getuserid();
      activity.ActivityDate = System.Today();
    //  activity.WhatId = getLoan().Id;
      activity.Status = 'In Progress';
      activity.subject = activity.Call_Results__c;
      activity.Priority = 'High';
      activity.IsReminderSet = true;

      if (activity.Call_Results__c == 'LM - Left message')
      {
          loan.Note_Date__c = System.Today();
          update loan;
      }

      if (activity.Hold_time__c != null)
      {
          loan.Note_Date__c = activity.Hold_date__c;
          update loan;
      }

      if (activity.Call_Results__c == 'Legal Review')
      {
          Account accountInf = [SELECT Id,Name,legal__c FROM account where id = : [select customer_number__c  from loan__c where id =: loan.Id].customer_number__c];
          accountInf.legal__c = true;
          upsert accountInf;
      }

      if (activity.Call_Results__c == PTP_STATUS_NAME)
      {                  
        activity.ReminderDateTime = makePromiseDate(activity);
        activity.Hold_date__c = activity.PTP_Date__c;
        activity.Hold_time__c = activity.PTP_Time__c;
        activity.PTP_TimeOnly__c = activity.PTP_Time__c.formatGmt('hh:mm a');
        loan.Note_Date__c = activity.Hold_date__c;
        loan.Has_PTP__c = true;
        update loan;
      }
      else
      {
        Time holdTime = null;
        if (activity.Hold_time__c != null)
        {
            holdTime = activity.Hold_time__c.time();
        }
        else
        {
            holdTime = Time.newInstance(0, 0, 0, 0);
        }
        activity.ReminderDateTime = DateTime.newInstance(activity.Hold_date__c, holdTime);
      }
      upsert activity;
//     acctPage = new ApexPages.StandardController(loan).view();
//     acctPage.setRedirect(true);
    }
    else
    {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'PTP Amount could not be greater than Total-to-current or less than 51% of Total-to-current.'));    
    }
    PageReference requestPage = Page.Congratulations;
    requestPage.setRedirect(true);
    return requestPage;
  }    
    
    public void is()
    { //activity.Hold_date__c = System.Today();
    }
    
    public void getIsEmpty()
    { //activity.Hold_date__c = System.Today();
      acctPage = new ApexPages.StandardController(loan).view();
      acctPage.setRedirect(true);
    }
/*    
    public PageReference cancel()
    { return new PageReference('/' + getLoan().Id);
    }   
*/    
}

 

VF page code is:

<apex:page standardController="Task" extensions="LogACallForCollections">
<apex:detail subject="{!task.id}"/>

....

</apex:page>

  • May 16, 2013
  • Like
  • 0

Apex class is:

public with sharing class LogACallForCollections
{
    public static final String PTP_STATUS_NAME = 'PTP - Promise to pay';
    public static final String PROMISE_STATUS_MADE = 'Made';
    public static final String PROMISE_STATUS_KEPT = 'Kept';
    public static final String PROMISE_STATUS_BROKEN = 'Broken';
    public static final String DEFAULT_USER_TYPE = 'collections';

    private Task activity;   
    private Loan__c loan;
    private PageReference acctPage;
    private PageReference requestPage;
    
    public Boolean required { get; set; }
    public Task task {get;set;}

    public LogACallForCollections(ApexPages.StandardController controller)
    {   
        List<Task> a = new List<Task>();
        if (controller != null)
        {
            task = (Task)controller.getRecord();
            a = [SELECT Id,
                               PTP_Date__c,
                               PTP_Time__c,
                               Promise_Status__c,
                               User_Type__c,
                               Hold_Date__c,
                               Hold_Time__c,
                               WhatId,
                               Action_Taken__c,
                               Call_Results__c,
                               PTP_Amount__c,
                               PTP_Method__c,
                               Source_of_Funds__c,
                               Description   
                        FROM Task WHERE id = :task.Id];
            loan = getLoanById(activity.WhatId);
        }
    }

    public LogACallForCollections()
    {
    }
   
    public void change()
    {
        if (activity.Call_Results__c == PTP_STATUS_NAME)
        {
            required = false;
        }
        else
        {
            required = true;        
        }
    }

    private Loan__c getLoanById(Id loanId) {
        Loan__c[] loans = [SELECT Id,
                                  Name,
                                  Loan_WV_Number__c,
                                  Total_to_Current__c,
                                  Customer_Home_Phone__c,
                                  Customer_Name__c,
                                  Customer_Cell_Phone__c,
                                  Joint_Customer_Full_Name__c,
                                  Joint_Customer_Phone__c
                           FROM Loan__c
                           WHERE id = :loanId];
        if (loans.size() > 0)
        {
            return loans.get(0);
        }                                     
        return null;
    }

    public Loan__c getLoan()
    {
        if (loan == null)
        {
            loan = getLoanById(ApexPages.currentPage().getParameters().get('id'));   
        }
        return loan;
    }
    
    public Integer getPtpTime()
    {
        if (activity != null)
        {
            return activity.PTP_Time__c.hour();        
        }
        return 0;
    }
    
    public void setPtpTime(Integer hour)
    {
        if (activity != null)
        {
            activity.PTP_Time__c = makePtpTime(hour);
        }   
    }
    
    public Integer getHoldTime()
    {
        if (activity != null)
        {
            if (activity.Hold_Time__c == null)
                return -1;
            else
                return activity.Hold_Time__c.hourGmt();    
        }
        return -1;
    }
    
    public void setHoldTime(Integer value)
    {
        if (activity != null)
        {
            if ( value == -1 )
                activity.Hold_Time__c = null;
            else
                activity.Hold_Time__c = Datetime.newInstanceGmt(1999, 1, 1, value, 0, 0);
        }   
    }  

    private DateTime makePtpTime(Integer hour)
    {
        return DateTime.newInstance(1999, 1, 1, hour, 0, 0);
    }

    public Task getActivity()
    {
        if (activity == null)
        {
            activity = new Task();
            activity.PTP_Date__c = System.today().addDays(1);
            activity.PTP_Time__c = makePtpTime(DateTime.now().hour());
            activity.Promise_Status__c = PROMISE_STATUS_MADE;
            activity.User_Type__c = DEFAULT_USER_TYPE;
            activity.Hold_Date__c = System.today().addDays(1);
            activity.Hold_Time__c = null;
        }
        return activity;
    }

    private Boolean checkPTPAmount()
    {
        if (activity.PTP_Amount__c == null || loan.Total_to_Current__c == null)
        {
            return false;
        }
        if ((activity.PTP_Amount__c > (loan.Total_to_Current__c * 0.51) || activity.PTP_Amount__c == 50.0) &&
             activity.PTP_Amount__c <= loan.Total_to_Current__c)
             {
                return true;
             }
        return false;
    }

    private Boolean checkPTPDate()
    {
        Date dt = System.today();
        dt.daysBetween(activity.PTP_Date__c);
        return (dt.daysBetween(activity.PTP_Date__c) < 0 || dt.daysBetween(activity.PTP_Date__c) >= 31);
    }

    private static DateTime makePromiseDate(Task task)
    {
        Date currDate = task.PTP_Date__c;
        Time currTime = task.PTP_Time__c.time();
        return DateTime.newInstance(currDate, currTime);
    }

    private Boolean checkTotalToCurrentAmount()
    {
        if (loan.Total_to_Current__c == null || loan.Total_to_Current__c == 0)
        {
            return true;
        }
        return false;
    }
    
  public PageReference Submit()
  {
      Boolean ptpF = PTP_STATUS_NAME.equals(activity.Call_Results__c);
      checkTotalToCurrentAmount();

//    System.debug('ptpF: ' + ptpF + ' && ' + 'checkTotalToCurrentAmount(): ' + checkTotalToCurrentAmount() );
    if (ptpF && checkTotalToCurrentAmount())
    {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'The Loan`s Total-to-current is 0.'));
        return acctPage;
    }
    checkPTPAmount();
    checkPTPDate();
//    System.debug('!ptpF: ' + !ptpF + '  ||  ( ptpF: ' + ptpF + ' && ' + 'checkPTPAmount(): ' + checkPTPAmount() + ')');
//    System.debug('if ( ptpF: ' + ptpF + ' && checkPTPDate(): ' + checkPTPDate());
    if (!ptpF || (ptpF && checkPTPAmount()))
    {
        if (ptpF && checkPTPDate())
        {
          ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'PTP Date can be for no more than 31 calendar days in the future.'));
          return acctPage;
        }

      activity.OwnerID = UserInfo.getuserid();
      activity.ActivityDate = System.Today();
    //  activity.WhatId = getLoan().Id;
      activity.Status = 'In Progress';
      activity.subject = activity.Call_Results__c;
      activity.Priority = 'High';
      activity.IsReminderSet = true;

      if (activity.Call_Results__c == 'LM - Left message')
      {
          loan.Note_Date__c = System.Today();
          update loan;
      }

      if (activity.Hold_time__c != null)
      {
          loan.Note_Date__c = activity.Hold_date__c;
          update loan;
      }

      if (activity.Call_Results__c == 'Legal Review')
      {
          Account accountInf = [SELECT Id,Name,legal__c FROM account where id = : [select customer_number__c  from loan__c where id =: loan.Id].customer_number__c];
          accountInf.legal__c = true;
          upsert accountInf;
      }

      if (activity.Call_Results__c == PTP_STATUS_NAME)
      {                  
        activity.ReminderDateTime = makePromiseDate(activity);
        activity.Hold_date__c = activity.PTP_Date__c;
        activity.Hold_time__c = activity.PTP_Time__c;
        activity.PTP_TimeOnly__c = activity.PTP_Time__c.formatGmt('hh:mm a');
        loan.Note_Date__c = activity.Hold_date__c;
        loan.Has_PTP__c = true;
        update loan;
      }
      else
      {
        Time holdTime = null;
        if (activity.Hold_time__c != null)
        {
            holdTime = activity.Hold_time__c.time();
        }
        else
        {
            holdTime = Time.newInstance(0, 0, 0, 0);
        }
        activity.ReminderDateTime = DateTime.newInstance(activity.Hold_date__c, holdTime);
      }
      upsert activity;
//     acctPage = new ApexPages.StandardController(loan).view();
//     acctPage.setRedirect(true);
    }
    else
    {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'PTP Amount could not be greater than Total-to-current or less than 51% of Total-to-current.'));    
    }
    PageReference requestPage = Page.Congratulations;
    requestPage.setRedirect(true);
    return requestPage;
  }    
    
    public void is()
    { //activity.Hold_date__c = System.Today();
    }
    
    public void getIsEmpty()
    { //activity.Hold_date__c = System.Today();
      acctPage = new ApexPages.StandardController(loan).view();
      acctPage.setRedirect(true);
    }
/*    
    public PageReference cancel()
    { return new PageReference('/' + getLoan().Id);
    }   
*/    
}

 

Vf page code is:

<apex:page standardController="Task" extensions="LogACallForCollections">
<apex:detail subject="{!task.id}"/>

....

</apex:page>

  • May 16, 2013
  • Like
  • 0

I receieve the following error with this Apex Controller

System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Bid__c.Name

Apex Controller:

public with sharing class RenderController
{
  public RFQ__C rfq {get; set;}
  public boolean privatefleet {get; set;}
  public boolean Dryvan{get; set;}
  public boolean Flatbed{get; set;}
  public boolean Reefer{get; set;}
  public boolean IMDL{get; set;}
  public boolean LTL{get; set;}
  public boolean RFI{get; set;}
  public Bid__c bid{get;set;}

  public RenderController()
  {
     rfq  = new  RFQ__C();
     String rfqid = Apexpages.Currentpage().getparameters().get('rfqid');
     rfq = [select name,f_Account_Owner__c,Account_Owner__c,Mode_s__c from RFQ__c where id=:rfqid];

     if(rfq.Mode_s__c.contains('Private Fleet'))
     {
       privatefleet = true;
       bid = [select Will_Load_Following_Trailers__c,Days_of_Week__c,Must_be_food_grade_trailer__c,Driver_Work__c,Lead_Time__c,Shipper_Hours_To__c,Shipper_Hours_From__c,Cons_Hours_To__c,Cons_Hours_From__c from Bid__C where RFQ__C=:rfqid and Modes__C = 'Private Fleet'];
     }

     if(rfq.Mode_s__c.contains('Dry Van'))
     {      
     }

     if(rfq.Mode_s__c.contains('Flatbed'))
     {
      Flatbed = true;
      bid = [select Ready_at__c,Securing_Accessories__C,Deliver_by__c,Level_of_flexibility__c,Are_moves_Over_Dimensional__c,Dimensions__c,Well_Space_Needed_or_Floor_Space__c,Tarps__c,Products_Overhang_on_Front_or_Rear__c from Bid__C where RFQ__C=:rfqid and Modes__C = 'Flatbed'];
     }

      if(rfq.Mode_s__c.contains('Reefer'))
     {
      Reefer= true;
      bid = [select Temp_Low_del__c,Temp_High_del__C from Bid__C where RFQ__C=:rfqid and Modes__C = 'Reefer'];
     }

      if(rfq.Mode_s__c.contains('IMDL'))
     {
      IMDL= true;
      bid = [select Container_Size__c,f_IMDL_Opportunity_Type__C,f_Shipment_Types__c,f_Current_IMDL_provider_types__c,f_Incumbent_IMDL_Providers__c,f_Other_IMDL_providers_notes__c from Bid__C where RFQ__C=:rfqid and Modes__C = 'IMDL'];
     }

      if(rfq.Mode_s__c.contains('LTL'))
     {
      LTL= true;
      bid = [select LTL_Class__c,Class_Distribution_Notes__C,FAK_Applicable__c,FAK_Notes__c,Tariff_Base_Year__c,FSC_Schedule__c from Bid__C where RFQ__C=:rfqid and Modes__C = 'LTL'];
     }

      if(rfq.Mode_s__c.contains('RFI'))
     {
       RFI= true;
       bid = [select RFI_Required__c,RFI_Status__C,RFI_Dependent__c,RFI_Due_Date__c from Bid__C where RFQ__C=:rfqid and Modes__C = 'RFI'];
     }
  }
  public pagereference save()
  {
   upsert bid;
   Pagereference pg = new Pagereference('/a0B/o');
   return pg;
  }
  public PageReference Cancel()
  {
    Pagereference pg = new Pagereference('/a01/o');
    return pg;
  }
 VF page:

<apex:page controller="RenderController" tabStyle="RFQ__c">
   <apex:form >
       <apex:sectionHeader title="RFQ Edit" subtitle="New RFQ"/>
       <apex:pageBlock id="rfqmain" title="RFQ Information" mode="Edit">
        <apex:pageBlockButtons >
         <apex:commandButton value="Save" action="{!save}"/>
         <apex:commandButton value="Cancel" action="{!Cancel}"/>
          </apex:pageBlockButtons>
          <apex:pageBlockSection title="RFQ Information">
            <apex:outputField value="{!rfq.name}"/>
            <apex:outputField value="{!rfq.f_Account_Owner__c}"/>
            <apex:outputField value="{!rfq.Account_Owner__c}"/>
            <apex:outputField value="{!rfq.Mode_s__c}"/>
          </apex:pageBlockSection>
          <apex:pageBlockSection title="Information">
             <apex:outputField value="{!bid.name}"/>
             <apex:outputField value="{!bid.Modes__c}"/>
             <apex:outputField value="{!bid.RFQ__c}"/>
             <apex:outputField value="{!bid.f_RFQ_Due_Date__c}"/>
             <apex:outputField value="{!bid.Lanes__c}"/>
             <apex:outputField value="{!bid.RFQ_Status__c}"/>
             <apex:outputField value="{!bid.Expected_LPD__c}"/>
             <apex:outputField value="{!bid.Bid_Status__c}"/>
             <apex:outputField value="{!bid.Bid_Stage__c}"/>
             <apex:outputField value="{!bid.FSC_Type__c}"/>
             <apex:outputField value="{!bid.FSC_Peg__c}"/>
             <apex:outputField value="{!bid.LPD_Goal__c}"/>
             <apex:outputField value="{!bid.Total_LPD__c}"/>   
             <apex:outputField value="{!bid.Send_to_Pricing_Team__c}"/>                                                                                                     
          </apex:pageBlockSection>
           <apex:pageBlockSection title="Notes">
             <apex:outputField value="{!bid.Notes__c}"/>
           </apex:pageBlockSection>         
             <apex:pageBlockSection title="private fleet" id="Privatefleet" rendered="{!Privatefleet}">
             <apex:inputField value="{!bid.Will_Load_Following_Trailers__c}"/>
             <apex:inputField value="{!bid.Days_of_Week__c}"/>
             <apex:inputField value="{!bid.Must_be_food_grade_trailer__c}"/>
             <apex:inputField value="{!bid.Driver_Work__c}"/>
             <apex:inputField value="{!bid.Lead_Time__c}"/>
             <apex:inputField value="{!bid.Shipper_Hours_To__c}"/>
             <apex:inputField value="{!bid.Shipper_Hours_From__c}"/>
             <apex:inputField value="{!bid.Cons_Hours_To__c}"/>
             <apex:inputField value="{!bid.Cons_Hours_From__c}"/>
           </apex:pageBlockSection>
           
           <apex:pageBlockSection title="Dry Van" id="Dryvan" rendered="{!Dryvan}">
           </apex:pageBlockSection>
                        
           <apex:pageBlockSection title="Flatbed" id="Flatbed" rendered="{!Flatbed}">
             <apex:inputField value="{!bid.Ready_at__c}"/>
             <apex:inputField value="{!bid.Securing_Accessories__c}"/>
             <apex:inputField value="{!bid.Deliver_by__c}"/>
             <apex:inputField value="{!bid.Level_of_flexibility__c}"/>
             <apex:inputField value="{!bid.Are_moves_Over_Dimensional__c}"/>
             <apex:inputField value="{!bid.Dimensions__c}"/>
             <apex:inputField value="{!bid.Well_Space_Needed_or_Floor_Space__c}"/>
             <apex:inputField value="{!bid.Tarps__c}"/>
             <apex:inputField value="{!bid.Products_Overhang_on_Front_or_Rear__c}"/>
           </apex:pageBlockSection>   
           
           <apex:pageBlockSection title="Reefer Requirements" id="Reefer" rendered="{!Reefer}">
             <apex:inputField value="{!bid.Temp_Low_del__c}"/>
             <apex:inputField value="{!bid.Temp_High_del__c}"/>
           </apex:pageBlockSection>  
           
           <apex:pageBlockSection title="Intermodal" id="IMDL" rendered="{!IMDL}">
             <apex:inputField value="{!bid.Container_Size__c}"/>
             <apex:inputField value="{!bid.f_IMDL_Opportunity_Type__c}"/>
             <apex:inputField value="{!bid.f_Shipment_Types__c}"/>
             <apex:inputField value="{!bid.f_Current_IMDL_provider_types__c}"/>
             <apex:inputField value="{!bid.f_Incumbent_IMDL_Providers__c}"/>
             <apex:inputField value="{!bid.f_Other_IMDL_providers_notes__c}"/>
           </apex:pageBlockSection>  

           <apex:pageBlockSection title="LTL" id="LTL" rendered="{!LTL}">
             <apex:inputField value="{!bid.LTL_Class__c}"/>
             <apex:inputField value="{!bid.Class_Distribution_Notes__c}"/>
             <apex:inputField value="{!bid.FAK_Applicable__c}"/>
             <apex:inputField value="{!bid.FAK_Notes__c}"/>
             <apex:inputField value="{!bid.Tariff_Base_Year__c}"/>
             <apex:inputField value="{!bid.FSC_Schedule__c}"/>
           </apex:pageBlockSection>
           
           <apex:pageBlockSection title="RFI" id="RFI" rendered="{!RFI}">
             <apex:inputField value="{!bid.RFI_Required__c}"/>
             <apex:inputField value="{!bid.RFI_Status__c}"/>
             <apex:inputField value="{!bid.RFI_Dependent__c}"/>
             <apex:inputField value="{!bid.RFI_Due_Date__c}"/>
           </apex:pageBlockSection>
           
           <apex:pageBlockSection title="System Information">
            <apex:outputField value="{!bid.CreatedBy}"/>
            <apex:outputField value="{!bid.LastModifiedBy}"/>
           </apex:pageBlockSection>
          
       </apex:pageBlock>
     </apex:form>
   </apex:page>

  • May 22, 2013
  • Like
  • 0

Apex class is:

public with sharing class LogACallForCollections
{
    public static final String PTP_STATUS_NAME = 'PTP - Promise to pay';
    public static final String PROMISE_STATUS_MADE = 'Made';
    public static final String PROMISE_STATUS_KEPT = 'Kept';
    public static final String PROMISE_STATUS_BROKEN = 'Broken';
    public static final String DEFAULT_USER_TYPE = 'collections';

    private Task activity;   
    private Loan__c loan;
    private PageReference acctPage;
    private PageReference requestPage;
    
    public Boolean required { get; set; }
    public Task task {get;set;}

    public LogACallForCollections(ApexPages.StandardController controller)
    {   
        List<Task> a = new List<Task>();
        if (controller != null)
        {
            task = (Task)controller.getRecord();
            a = [SELECT Id,
                               PTP_Date__c,
                               PTP_Time__c,
                               Promise_Status__c,
                               User_Type__c,
                               Hold_Date__c,
                               Hold_Time__c,
                               WhatId,
                               Action_Taken__c,
                               Call_Results__c,
                               PTP_Amount__c,
                               PTP_Method__c,
                               Source_of_Funds__c,
                               Description   
                        FROM Task WHERE id = :task.Id];
            loan = getLoanById(activity.WhatId);
        }
    }

    public LogACallForCollections()
    {
    }
   
    public void change()
    {
        if (activity.Call_Results__c == PTP_STATUS_NAME)
        {
            required = false;
        }
        else
        {
            required = true;        
        }
    }

    private Loan__c getLoanById(Id loanId) {
        Loan__c[] loans = [SELECT Id,
                                  Name,
                                  Loan_WV_Number__c,
                                  Total_to_Current__c,
                                  Customer_Home_Phone__c,
                                  Customer_Name__c,
                                  Customer_Cell_Phone__c,
                                  Joint_Customer_Full_Name__c,
                                  Joint_Customer_Phone__c
                           FROM Loan__c
                           WHERE id = :loanId];
        if (loans.size() > 0)
        {
            return loans.get(0);
        }                                     
        return null;
    }

    public Loan__c getLoan()
    {
        if (loan == null)
        {
            loan = getLoanById(ApexPages.currentPage().getParameters().get('id'));   
        }
        return loan;
    }
    
    public Integer getPtpTime()
    {
        if (activity != null)
        {
            return activity.PTP_Time__c.hour();        
        }
        return 0;
    }
    
    public void setPtpTime(Integer hour)
    {
        if (activity != null)
        {
            activity.PTP_Time__c = makePtpTime(hour);
        }   
    }
    
    public Integer getHoldTime()
    {
        if (activity != null)
        {
            if (activity.Hold_Time__c == null)
                return -1;
            else
                return activity.Hold_Time__c.hourGmt();    
        }
        return -1;
    }
    
    public void setHoldTime(Integer value)
    {
        if (activity != null)
        {
            if ( value == -1 )
                activity.Hold_Time__c = null;
            else
                activity.Hold_Time__c = Datetime.newInstanceGmt(1999, 1, 1, value, 0, 0);
        }   
    }  

    private DateTime makePtpTime(Integer hour)
    {
        return DateTime.newInstance(1999, 1, 1, hour, 0, 0);
    }

    public Task getActivity()
    {
        if (activity == null)
        {
            activity = new Task();
            activity.PTP_Date__c = System.today().addDays(1);
            activity.PTP_Time__c = makePtpTime(DateTime.now().hour());
            activity.Promise_Status__c = PROMISE_STATUS_MADE;
            activity.User_Type__c = DEFAULT_USER_TYPE;
            activity.Hold_Date__c = System.today().addDays(1);
            activity.Hold_Time__c = null;
        }
        return activity;
    }

    private Boolean checkPTPAmount()
    {
        if (activity.PTP_Amount__c == null || loan.Total_to_Current__c == null)
        {
            return false;
        }
        if ((activity.PTP_Amount__c > (loan.Total_to_Current__c * 0.51) || activity.PTP_Amount__c == 50.0) &&
             activity.PTP_Amount__c <= loan.Total_to_Current__c)
             {
                return true;
             }
        return false;
    }

    private Boolean checkPTPDate()
    {
        Date dt = System.today();
        dt.daysBetween(activity.PTP_Date__c);
        return (dt.daysBetween(activity.PTP_Date__c) < 0 || dt.daysBetween(activity.PTP_Date__c) >= 31);
    }

    private static DateTime makePromiseDate(Task task)
    {
        Date currDate = task.PTP_Date__c;
        Time currTime = task.PTP_Time__c.time();
        return DateTime.newInstance(currDate, currTime);
    }

    private Boolean checkTotalToCurrentAmount()
    {
        if (loan.Total_to_Current__c == null || loan.Total_to_Current__c == 0)
        {
            return true;
        }
        return false;
    }
    
  public PageReference Submit()
  {
      Boolean ptpF = PTP_STATUS_NAME.equals(activity.Call_Results__c);
      checkTotalToCurrentAmount();

//    System.debug('ptpF: ' + ptpF + ' && ' + 'checkTotalToCurrentAmount(): ' + checkTotalToCurrentAmount() );
    if (ptpF && checkTotalToCurrentAmount())
    {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'The Loan`s Total-to-current is 0.'));
        return acctPage;
    }
    checkPTPAmount();
    checkPTPDate();
//    System.debug('!ptpF: ' + !ptpF + '  ||  ( ptpF: ' + ptpF + ' && ' + 'checkPTPAmount(): ' + checkPTPAmount() + ')');
//    System.debug('if ( ptpF: ' + ptpF + ' && checkPTPDate(): ' + checkPTPDate());
    if (!ptpF || (ptpF && checkPTPAmount()))
    {
        if (ptpF && checkPTPDate())
        {
          ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'PTP Date can be for no more than 31 calendar days in the future.'));
          return acctPage;
        }

      activity.OwnerID = UserInfo.getuserid();
      activity.ActivityDate = System.Today();
    //  activity.WhatId = getLoan().Id;
      activity.Status = 'In Progress';
      activity.subject = activity.Call_Results__c;
      activity.Priority = 'High';
      activity.IsReminderSet = true;

      if (activity.Call_Results__c == 'LM - Left message')
      {
          loan.Note_Date__c = System.Today();
          update loan;
      }

      if (activity.Hold_time__c != null)
      {
          loan.Note_Date__c = activity.Hold_date__c;
          update loan;
      }

      if (activity.Call_Results__c == 'Legal Review')
      {
          Account accountInf = [SELECT Id,Name,legal__c FROM account where id = : [select customer_number__c  from loan__c where id =: loan.Id].customer_number__c];
          accountInf.legal__c = true;
          upsert accountInf;
      }

      if (activity.Call_Results__c == PTP_STATUS_NAME)
      {                  
        activity.ReminderDateTime = makePromiseDate(activity);
        activity.Hold_date__c = activity.PTP_Date__c;
        activity.Hold_time__c = activity.PTP_Time__c;
        activity.PTP_TimeOnly__c = activity.PTP_Time__c.formatGmt('hh:mm a');
        loan.Note_Date__c = activity.Hold_date__c;
        loan.Has_PTP__c = true;
        update loan;
      }
      else
      {
        Time holdTime = null;
        if (activity.Hold_time__c != null)
        {
            holdTime = activity.Hold_time__c.time();
        }
        else
        {
            holdTime = Time.newInstance(0, 0, 0, 0);
        }
        activity.ReminderDateTime = DateTime.newInstance(activity.Hold_date__c, holdTime);
      }
      upsert activity;
//     acctPage = new ApexPages.StandardController(loan).view();
//     acctPage.setRedirect(true);
    }
    else
    {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'PTP Amount could not be greater than Total-to-current or less than 51% of Total-to-current.'));    
    }
    PageReference requestPage = Page.Congratulations;
    requestPage.setRedirect(true);
    return requestPage;
  }    
    
    public void is()
    { //activity.Hold_date__c = System.Today();
    }
    
    public void getIsEmpty()
    { //activity.Hold_date__c = System.Today();
      acctPage = new ApexPages.StandardController(loan).view();
      acctPage.setRedirect(true);
    }
/*    
    public PageReference cancel()
    { return new PageReference('/' + getLoan().Id);
    }   
*/    
}

 

Vf page code is:

<apex:page standardController="Task" extensions="LogACallForCollections">
<apex:detail subject="{!task.id}"/>

....

</apex:page>

  • May 16, 2013
  • Like
  • 0