function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rick MacGuiganRick MacGuigan 

List type not populating

Having a problem with following code. On the controller, the list 'contractNumbers' is not being populated with values. There are no errors on the controller nor visualForce page. The view state shows 'contractNumbers' as an empty list. This results in nothing returned in the queries that use 'contractNumbers' as an input parm. 

Could use a second pair of eyes . Thanks. 

CONTROLLER:
public class AccountSummaryController {
  //Constants
  public static final string SUMMARY_RECORD_TYPE_NAME = 'Summary Record Type';
  public static final string URL_PARAM_RECORD_TYPE_ID = 'RecordType';
  public static final string URL_PARAM_ACCOUNT_ID = 'accid';
  public static final string URL_PARAM_EXTERNAL_ID = 'exid';
  public static final string URL_PARAM_SUBMISSION_YEAR = 'syear';

  //Properties
  public Id RecordTypeId {get;set;}
  public Id AccountId {get;set;}
  public string ExternalId {get;set;}
  public string SubmissionYear {get;set;}
  public String ContractYear {get;set;}
  public Account_Summary__c AccountSummary {get;set;}
  public Set<Id> sbIdSet;
  public List<string> contractNumbers = new List<string>();
  
  public List<SelectOption> SubmissionOptions {get;set;}
  public List<Id> SelectedSubmissions {get;set;}
  public List<Submissions__c> submissionList {get;set;}
  public List<MR_Contracts__c> contractList {get;set;}
  public List<Contract_Sections__c> contractSectionList {get;set;}
  public List<Contract_Sections__c> contractQSSectionList {get;set;} 
  public List<MR_Contracts__c> PriorYRcontractSectionList {get;set;}   

     
  public Account ParentAcct {get;set;}

  //Protected Members
  private final string accountIdPrefix;

  //Constructors
  public AccountSummaryController(ApexPages.StandardController controller) {
    try {
      this.AccountSummary = (Account_Summary__c) controller.getRecord();
      this.ParentAcct = new Account();
      
      //Get Url Parameters
      Map<string, string> params = ApexPages.currentPage().getParameters();
      this.RecordTypeId = params.get(URL_PARAM_RECORD_TYPE_ID);
      this.AccountId = params.get(URL_PARAM_ACCOUNT_ID);
      this.ExternalId = params.get(URL_PARAM_EXTERNAL_ID);
      this.SubmissionYear = params.get(URL_PARAM_SUBMISSION_YEAR);
      this.ContractYear = string.valueof((integer.valueof(SubmissionYear)-1));
     
      sbIdSet = new Set<Id>();      
      SelectedSubmissions = new List<String>();
      this.AccountSummary.Name = params.get(URL_PARAM_SUBMISSION_YEAR);

      //Get Audit Id Prefix

      Schema.DescribeSObjectResult dsr = Account.sObjectType.getDescribe();  // errored when 
      this.accountIdPrefix = dsr.getKeyPrefix();    

      //Get Account Id
         Id AccountId = this.AccountSummary.Account_Name__c;
                
         if (AccountId == null) {
              string param1 = ApexPages.currentPage().getParameters().get('AccId');
                
               if (isAccountId(param1)) {
                    AccountId = param1;
                }
               else {              
                    ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'Invalid Audit Id. Please contact the help desk with this error'));
                }
            }


//Load Account Record
            List<Account> accounts = queryAccounts(AccountId);
            if (accounts.isEmpty() == true) {
            
              ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'No records were found. Please contact the help desk with this error'));                          
    
            }
            else if (accounts.size() > 1) {
            
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'More than 1 record found. Please contact the help desk with this error'));
            
            }
            else {
                this.ParentAcct = accounts[0];
                this.AccountSummary.Account_Name__c = this.ParentAcct.Id;

            }
            //Get Options      
            this.SubmissionOptions = getSubmissionOptions(this.ExternalId, this.SubmissionYear);
            //used to fetch all submission options
        
        
        }
        catch (Exception ex) {
            ApexPages.addMessages(ex);
        }

    }



  //Public Methods

public void getSelectedSubmissions() {
// called by command button 'Select Submissions'
    try {
      this.submissionList = querySubmissionsById(this.SelectedSubmissions); 
 
      for (Submissions__c sublist : submissionList) {
      string val1 = sublist.Name; //Just an example. Change as needed
      string val2 = sublist.SPD_REF_PS__c; 
      string val3 = sublist.Company_Code__c;      
      string contractNumber = val2 + this.ContractYear + val3;
      contractNumbers.add(contractNumber);    /// <<< LIST RESULTS ARE NULL 
    }      
 
      this.contractSectionList = querycontractsectionById(contractNumbers, this.ContractYear);  
    }
    catch (Exception ex) {
      ApexPages.addMessages(ex);
    }
  }


  //Private Methods
  private List<SelectOption> getSubmissionOptions(string externalId, string year) {
    List<SelectOption> options = new List<SelectOption>();

    List<Submissions__c> subs = querySubmissionsByExternalIdAndYear(externalId, year);
    for (Submissions__c sub : subs) {
      string value = sub.Id;
      
      Date myDate = sub.Est_CERT_Incept_Date_PS__c;
      String inceptionDate = sub.Est_CERT_Incept_Date_PS__c.format();
      string label = sub.SPD_REF_PS__c + ' - ' + sub.Submission_Yr_PS__c + ' - ' + sub.Submission_Status_PS__c + ' - ' + inceptionDate + ' - ' + sub.LOB_Program__c;
      options.add(new SelectOption(value, label));
    }

    return options;
  }

  //Query Methods
  
    //Private Methods
    private boolean isAccountId(string value) {
        boolean isValid = false;

        if (value != null && value.length() >= 15 && value.length() <= 18) {
            isValid = value.startsWith(accountIdPrefix);
        }

        return isValid;
    }



  private List<MR_Contracts__c> querycontractsById(List<String> contractIds, string ContractYear) {
   //used to display Contract Summary Data based on user selected submissions for the multiselect field. 
    return [
      SELECT
        Id
        ,Name
        ,SUBJECT_PREMIUM_PS__c
        ,BROKERAGE__c
        ,Commission_PS__c
       FROM
        MR_Contracts__c
      WHERE
        ContractSubmissionRef__c IN :contractIds
      AND
        //Underwriting_Year_spd_yr_PS__c=:contractYear
        Underwriting_Year_spd_yr_PS__c=:'2015'
    ORDER BY Name
    ];
  }

  
  private List<Submissions__c> querySubmissionsById(List<Id> submissionsIds) {
   //used to display contract information based on user selected submissions from the multiselect field.
   //reuses submissionsIds tha  
    return [
      SELECT
        Id
        ,SPD_REF_PS__c
        ,Submission_Yr_PS__c
        ,Producing_Broker_Full__c
        ,Key_Broker_Contact_LU_PS__c
        ,Est_CERT_Incept_Date_PS__c
        ,Submission_New_Renew_PS__c
        ,CLARIFY_TYPE_PS__c        
        ,Coverage_PS__c
        ,Submission_Structure_PS__c

      FROM
        Submissions__c
      WHERE
        Id IN :submissionsIds
    ];
  }  
  

  private List<Submissions__c> querySubmissionsByExternalIdAndYear(string externalId, string submissionYear) {
  //used to display all submission options for the multiselect field. 
    return [
      SELECT
        Id
        ,Name
        ,SPD_REF_PS__c
        ,Submission_Status_PS__c
        ,LOB_Program__c
        ,Submission_Yr_PS__c
        ,Est_CERT_Incept_Date_PS__c
      FROM
        Submissions__c
      WHERE
        External_ID_BA__c=:externalId
        AND
        Submission_Yr_PS__c=:submissionYear
    ];
  }


    private List<Account> queryAccounts(Id acctId) {
        List<Account> accounts = new List<Account>();

        if (acctId != null) {
            accounts = [SELECT 
                        Id
                        , Name
                        , Cedent_RIC_Best_Rating_PS__c
                        , External_ID_BA__c                              
                FROM 
                    Account 
                WHERE 
                    Id = :acctId];
        }

        return accounts;
    }
  
}

VisualForce Page: 
 
<apex:page standardController="Account_Summary__c" readOnly="false" extensions="AccountSummaryController" >
<!----------------------#######----------------------->
<!--Formatting Styles -->   
<style>
  .headerRow .TableTitle {
    background-color: #F0F8FF !important;
    background-image: none !important; //This is needed if you want to overwrite the header background
    color: #CC0000 !important; 
    font-size:100% !important; 
  }
</style>  
<!-------------------------------------------------->  
  
<!-------------------------------------------------->
<!--Controller Information variables --> 
<!-- declare variable for Parent Audit ID dependency to SOQL field in controller. --> 
<apex:variable var="Acct" value="{!ParentAcct}" /> 

<!--Page Default variables --> 
<apex:variable var="ParentID" value="{!Acct.Id}" />
<apex:variable var="AccountName" value="{!Acct.Name}" />


<!-- <apex:variable var="a" value="{!audit}" /> -->
<apex:variable var="acctsum" value="{!Account_Summary__c}" />

<!--Account Summary control variables -->
<apex:variable var="BestRating" value="{!acctsum.BestRating__c}" />
<!--<apex:variable var="AccountName" value="{!accounts.Name}" /> -->


<!-------------------------------------------------->

<apex:form id="form1">
<apex:pageMessages id="globalMessages" />

<apex:sectionHeader title="New (VF) Comprehensive Risk Evaluation" subtitle="Comprehensive Risk Evaluation" help="{!$Resource.Help_MaidenReUWGuidelines}"/>

<apex:messages title="data incorrectly entered." style="background-color:yellow; color: red" /> 

<apex:pageBlock id="block1" title="Comprehensive Risk Evaluation - General Information" >

<!--<apex:outputPanel layout="none" rendered="{!IsNew}" >  -->
<apex:outputPanel layout="none" rendered="true" >
<b>Sample Ref:</b> &nbsp;  <apex:outputField value="{!Account_Summary__c.Name}"  /> 
</apex:outputPanel> 


<!--<apex:outputPanel layout="none" rendered="{!IsNew=false}" >  -->
<apex:outputPanel layout="none" rendered="true" >
<p>
<b>Sample Ref:</b> &nbsp; <apex:outputField value="{!Account_Summary__c.Name}"  /> &nbsp; <br>
<b>Policy:</b>  &nbsp; <apex:outputField value="{!Account_Summary__c.Account_Name__c}"/> &nbsp; ( 
 <apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
  <apex:param value="{!Account_Summary__c.CreatedDate}" /> 
 </apex:outputText> 
) </br> </p> 


<apex:outputText value="{0,date} {0,time}">
<b>Driver Created: </b> &nbsp;  <apex:param value="{!Account_Summary__c.CreatedDate}"/>  
</apex:outputText> 
by: &nbsp; <apex:outputField value="{!Account_Summary__c.CreatedById}"/> &nbsp; <b> Last Modified By: </b>  <apex:outputField value="{!Account_Summary__c.LastModifiedById}"/>  on &nbsp; 
<apex:outputField value="{!Account_Summary__c.LastModifiedDate}"/>
</apex:outputPanel> 


<p><b>Hello {!$User.FirstName}!</b> &nbsp; <font color='blue'> Enter Comprehensive Risk Evaluation information below. </font> </p>
<!-- automate helper text for potential user instruction --> 
  <apex:outputText style="font-style:italic;background-color:yellow;color:blue" value="sample instruction text ??" />

<!-- enable display of messages for all conditions --> 
<apex:messages title="data incorrectly entered." style="background-color:yellow; color: red" /> 

<apex:pageBlockButtons >
<!-- <apex:commandButton value="Save Only" action="{!Save}"/> -->
</apex:pageBlockButtons>

<!--Debug info for state changes set rendered="true" to enable section -->
<!-- Control state information - DO NOT DELETE THIS  set rendered="true" to display this section -->
<apex:pageBlockSection columns="1" id="testsection1" title="General Information" rendered="false"> 
<!-- ....Parent ID Number is : "{!a.Policy_Number__c}"<br></br> -->
<!--
<p><font color='blue'>//Account Summary control variables </font></p>
BestRating is : "{!BestRating}"<br></br> 
//-->

</apex:pageBlockSection>

<!-- script used to collapse sections initially. Otherwise they do not trigger event -->
<script>twistSection(document.getElementById("{!$Component.testsection1}").childNodes[0].childNodes[0]); </script>

<!-- GENERAL INFORMATION -->

<apex:pageBlockSection columns="1" id="section1" title="General Information" showHeader="true" >

 <!-- setting required='true' will bypass field validation if field is not rendered -->

 <apex:inputField value="{!Account_Summary__c.Name}" required="false" />
<apex:inputField value="{!Account_Summary__c.Program_Name__c}" required="false"  >
     <apex:actionSupport event="onchange" reRender="section1" />
     </apex:inputField>  
 <apex:inputField value="{!Account_Summary__c.Report_Status__c}"  />
       
 <apex:inputField value="{!acctsum.Effective_Date__c}" />
<apex:inputField value="{!acctsum.TreatyType__c}"  />
<apex:inputField value="{!acctsum.Program_Structure__c}"  />
<apex:inputField value="{!acctsum.Requested_Quote_Date__c}"  />
<apex:inputField value="{!acctsum.Key_Contract_Terms__c}"  />  
 <apex:inputField value="{!acctsum.Is_there_an_MGA_binding_business__c}"  />  
 <apex:inputField value="{!acctsum.Is_there_an_outside_TPA_handling_claims__c}"  />    

<apex:inputField value="{!acctsum.UW_Referral_Required__c}"  /> 
<apex:inputField value="{!acctsum.Presidential_Review_Required__c}"  /> 
<apex:inputField value="{!acctsum.Is_UW_audit_required__c}"  /> 
<apex:inputField value="{!acctsum.Estimated_Subject_Premium__c}"  /> 
 
 
 <apex:outputField value="{!acctsum.Account_Name__c}"/> 
 <apex:inputField value="{!acctsum.Underwriter_Assigned__c}" />  
 <apex:outputField value="{!Acct.Cedent_RIC_Best_Rating_PS__c}"/>

 <!-- <apex:outputField value="{!acctsum.MRY_Surplus_as_Regards_Policyholders__c}"/> -->
<!-- <apex:outputField value="{!acctsum.MRY_Net_Premiums_Written__c}"/> -->
<!-- <apex:outputField value="{!acctsum.MRY_Combined_Ratio__c}"/> -->
  
 <apex:actionRegion >
<apex:pageBlockSection columns="1" showHeader="false"  >
<apex:inputField value="{!Account_Summary__c.Lines_of_Business__c}" >
    <apex:actionSupport event="onchange" reRender="LOB" />
    </apex:inputField>
</apex:pageBlockSection> 
 </apex:actionRegion>   
     
 <apex:outputPanel id="LOB">
<apex:pageBlockSection columns="1" showHeader="false"  >           
 <apex:inputField value="{!Account_Summary__c.Other_Line_of_Business__c}"  style="color:blue;" rendered="{!CONTAINS(Account_Summary__c.Lines_of_Business__c,'Other')}" /> 
 </apex:pageBlockSection>
</apex:outputPanel>



</apex:pageBlockSection>
<!-- script used to collapse sections initially. Otherwise they do not trigger event -->
<script>twistSection(document.getElementById("{!$Component.testsection1}").childNodes[0].childNodes[0]); </script>

<!-- >>>>>>>>>>>  -->
  <!-- automate helper text for potential user instruction --> 
  <apex:outputText style="font-style:italic;background-color:yellow;color:blue" value="Select submissions that apply to the program. " />
   <br></br>
   <!--  <apex:actionRegion immediate="true">  -->
      <apex:actionRegion > 
       <apex:selectList value="{!SelectedSubmissions}" multiselect="true">
         <apex:selectOptions value="{!SubmissionOptions}"/>
       </apex:selectList><p/>
        
           <apex:commandButton value="Select Submissions" action="{!getSelectedSubmissions}" rerender="out2a,out2b,out2ba,out2c,out2d,out3a,out3b,out8" status="status"/>
   </apex:actionRegion>



<!-- SUBMISSION CONTRACT INFORMATION -->
<apex:pageBlockSection columns="1" id="section2b" title="* Expiring Excess of Loss Contract Information" showHeader="true" > 
 
             <apex:outputPanel id="out2b">
                <apex:actionstatus startText="loading...">
                    <apex:facet name="stop" >
                        <apex:outputPanel >
                            

                            <apex:dataTable value="{!contractSectionList}" var="cs" rules="all" cellpadding="5" >
                            
                                <apex:column value="{!cs.MR_Contract__c}" headerValue="Contract"/>
                                <apex:column value="{!cs.Name}" headerValue="Section"/>
                                <apex:column value="{!cs.RSO_RTC_CODE__c}" headerValue="Type"/>
                                 
                                <apex:column value="{!cs.Renewal_Date__c}" headerValue="Eff Date"/>                                
                                <apex:column value="{!cs.SUBJECT_PREMIUM__c}" headerValue="Subject Premium"/>  
                                <apex:column value="{!cs.Limit__c}" headerValue="Treaty Limit"/>  
                                <apex:column value="{!cs.Retention__c}" headerValue="Treaty Attachment"/>  
                                <apex:column value="{!cs.Maximum_Loss__c}" headerValue="Aggregate Limit"/> 
                                <apex:column value="{!cs.AAD__c}" headerValue="AAD"/>
                                <apex:column value="{!cs.Participation__c}" headerValue="Maiden Re Part%"/>                                
                                <apex:column value="{!cs.Estimated_Premium__c}" headerValue="MaidenRe Premium"/>                                
                                <apex:column value="{!cs.Maiden_Re_Limit__c}" headerValue="Maiden Re Limit"/>                   
                                <apex:column value="{!cs.Attachment_Type__c}" headerValue="Attachment Type"/>
                                <apex:column value="{!cs.RSO_LAE_TYPE__c}" headerValue="LAE Type"/>
                                <apex:column value="{!cs.FLAT_SWING_COMM_RATE__c}" headerValue="Ceding Commission"/>                                
                                <apex:column value="{!cs.PROFIT_COMM_RATE__c}" headerValue="Profit Commission"/>                                
                                <apex:column value="{!cs.PROFIT_COMM_PNCT__c}" headerValue="Expense for PC"/>
                               <apex:column value="{!cs.Ceding_Comm_Min__c}" headerValue="Swing Min Rate"/>                                
                                <apex:column value="{!cs.Ceding_Comm_Prov__c}" headerValue="Swing Prov Rate"/>                                
                                <apex:column value="{!cs.Ceding_Comm_Max__c}" headerValue="Swing Max Rate"/>  
                                <apex:column value="{!"-"}" headerValue="Loss Load for Swing"/>
                                <apex:column value="{!cs.RSO_ESO_PCNT__c}" headerValue="ECO%"/>
                                <apex:column value="{!cs.RSO_XPL_PCNT__c}" headerValue="XPL%"/>
                                <apex:column value="{!cs.Brokerage__c}" headerValue="Brokerage"/> 
                                                           
                            </apex:dataTable>    
                                                    
                        </apex:outputPanel>
                    </apex:facet>
                </apex:actionstatus>
            </apex:outputPanel>


 </apex:pageBlockSection>



<!-- SUBMISSION SUMMARY -->
<apex:pageBlockSection columns="1" id="section2a" title="(WIP) Submission Summary Information" showHeader="true" >

           
            <apex:outputPanel id="out2a">
                <apex:actionstatus id="status" startText="loading...">
                    <apex:facet name="stop">
                        <apex:outputPanel >
                           <!-- <p><b>Submission Summary Information:</b></p> -->
                                                      
                            <apex:dataTable value="{!submissionList}" var="s" rules="all" cellpadding="5" rows="1" >
                                <!-- <apex:column value="{!s.name}"/> -->                                
                                <apex:column value="{!s.Producing_Broker_Full__c}" headerValue="Producing Broker - Location" headerClass="TableTitle" />                            
                                <apex:column value="{!s.Key_Broker_Contact_LU_PS__c}" headerValue="Key Contact" />
                            </apex:dataTable>  
                            <br></br>
                            <apex:dataTable value="{!submissionList}" var="s" rules="all" cellpadding="5" >
                                <!-- <apex:column value="{!s.name}"/> -->
                                <apex:column value="{!s.SPD_REF_PS__c}" headerValue="Submission"/>
                               <apex:column value="{!s.Est_CERT_Incept_Date_PS__c}" headerValue="Inception Date"/>                                
                                <apex:column value="{!s.Submission_New_Renew_PS__c}" headerValue="New/Renewal"/>
                                <!--
                                <apex:column headerValue="Renewed as Expired?">
                                 <apex:inputField value="{!s.Renew_as_Expired__c}"/> 
                                </apex:column> 
                                //-->                               
                                <apex:column value="{!s.CLARIFY_TYPE_PS__c}" headerValue="Treaty Type"/>
                                <apex:column value="{!s.Coverage_PS__c}" headerValue="Coverage"/>
                                
                                <apex:column value="{!"--"}" headerValue="Maiden Re Part%"/>                                
                                <apex:column value="{!"--"}" headerValue="QS Part of %"/>                                
                                <apex:column value="{!"--"}" headerValue="Cession Limit"/>                                
                                <apex:column value="{!"--"}" headerValue="Treaty Limit"/>                                
                                <apex:column value="{!"--"}" headerValue="Maiden Re Limit"/>                                
                                <apex:column value="{!"--"}" headerValue="Event Limit"/> 
                                <apex:column value="{!"--"}" headerValue="Attachment Type"/>                                
                                <apex:column value="{!"--"}" headerValue="LAE Type"/>                                
                                <apex:column value="{!"--"}" headerValue="ECO%"/>                                
                                <apex:column value="{!"--"}" headerValue="XPL%"/>                                                               
                                <apex:column value="{!"--"}" headerValue="Requested Brokerage"/>                                 
                                <apex:column value="{!"--"}" headerValue="Requested Reinstatements"/>
                            </apex:dataTable>                                
                            
                                                    
                        </apex:outputPanel>
                    </apex:facet>
                </apex:actionstatus>
            </apex:outputPanel>

</apex:pageBlockSection>


<!-------------------------------------------------->
</apex:pageBlock>
</apex:form>
<apex:relatedList list="AttachedContentNotes" />
<apex:relatedList list="AttachedContentDocuments" />
<!----------------------#######----------------------->
</apex:page>


 
Best Answer chosen by Rick MacGuigan
Alain CabonAlain Cabon
querycontractsectionById is missing above.

There is only querycontractsById.

All Answers

Alain CabonAlain Cabon
querycontractsectionById is missing above.

There is only querycontractsById.
This was selected as the best answer
Rick MacGuiganRick MacGuigan
Thanks for you response Alain.