• myprofile
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hi all,

 

I dont know what am i doing wrong. Probably an extra pair of eyes might help. I have this dynamic SOQL query and I am getting the values from the VisualForce Page. But somehow i dont see anything on the page:

 

Here is my controller Code:

 

public With Sharing class newScoreRuleController { public List<ScoringRule__c> ScoringRule { get; private set;} public List<showLeads> searchResults = new List<showLeads>(); String ViewBy = ''; String fldDate; Date StartDate; Date EndDate; public string getViewBy() { return this.ViewBy; } public String getFldDate() { return this.fldDate ; } public Date getStartDate() { return this.StartDate ; } public Date getEndDate() { return this.EndDate ; } public void setViewBy(string val) { this.ViewBy = val; } public void setFldDate(String val) { this.fldDate = val; } public void setStartDate(Date val) { this.StartDate = val; } public void setEndDate(Date val) { this.EndDate = val; } // Add leads Options
public List<SelectOption> getLeadView() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('myleads','My Leads'));
options.add(new SelectOption('myteamleads','My Team Leads'));
options.add(new SelectOption('alleads','All Leads'));
return options;
}

// Get Date Options
public List<SelectOption> getDateOptions() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('CreatedDate','Created Date'));
options.add(new SelectOption('lastModifiedDate','Last Modified'));
options.add(new SelectOption('lastAcitivityDate','Last Acitivty'));
return options;
}

 

public List<Lead> getLead() { if(lead == null) lead = new Lead(); // Get Leads based on the selected Value String leadQry = 'select FirstName, LastName, NumberOfEmployees,' + 'AnnualRevenue from lead where ' + ViewBy + ' >= ' + StartDate + ' and ' + ViewBy + ' <= ' + EndDate; System.debug('************ Query: ************ ' + leadQry); List <Lead> leads = Database.Query(leadQry); return leads; } public String ApplyScoringRule() { // Now set the method depending on what it is; List<Lead> results = getLead(); // If zero or more than 250 records returned, display a message if (results.size() == 250) ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'NOTE: Only the first 250 rows are displayed.')); if (results.size() == 0) ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'NO RECORDS FOUND.')); // Build the searchResults[] list used by the Apex:DataTable tag on the page for (Lead c : results) { // System.Debug(); searchResults.add( new showLeads(c) ) ; } return null; } Public Class showLeads{ public boolean selected = true; public Lead l = null; public showLeads() { } public showLeads(Lead lr) { lr = l; } public Lead getShowLeads() { return this.l ; } public void setShowLeads(Lead ls) { this.l = ls; } } }

 

 Here is my Visual Controller Code:

 

<apex:page controller="newScoreRuleController" tabStyle="Lead"> <apex:sectionHeader title="Score your leads"/> <apex:form > <apex:pageBlock title="Select Leads that you want to score" mode="edit"> <apex:pageBlockButtons > <apex:commandButton action="{!applyScoringRule}" value="Apply Scoring Rule"/> <apex:commandButton action="{!cancel}" value="Cancel" onclick="return confirmCancel()" immediate="true"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Selection Criteria"> <apex:outputLabel value="Date:"/> <apex:selectList id="date" multiselect="false" value="{!fldDate}" required="true" size="1"> <apex:selectOptions value="{!dateOptions}"></apex:selectOptions> </apex:selectList> <apex:outputLabel value="Start date:" for="startDate"/> <input id="startDate" name="startDate" value="{!$CurrentPage.parameters.startDate}" size="7" maxlength="10" />(yyyy-mm-dd) &nbsp;&nbsp;&nbsp; <apex:outputLabel value="End date:" for="endDate"/> <input id="endDate" name="endDate" value="{!$CurrentPage.parameters.endDate}" size="7" maxlength="10" />(yyyy-mm-dd) <!-- Within a pageBlockSection, inputFields always display with their corresponding output label. --> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>

 

 

 

 Any help is appreciated!!

 

Thanks again!

 

 

  • June 22, 2009
  • Like
  • 0