+ Start a Discussion
RAMANJINEYULU GOGULARAMANJINEYULU GOGULA 

I want to fetch value from one method to another method

public with sharing class salescontroller 
{
    public string dat='this month';
   public Integer leadcount{ get; set; }
   
    public Integer getCountings()
    {
       Integer counts=[SELECT COUNT() FROM Lead];
       leadcount=counts;
        return counts;
    }
    public List<Lead> getCurrentMonthInfo()
    {
        List<Lead> ll=Database.query('SELECT Id,Name,Division_Name__c,Title,counting__c '+ 'FROM Lead');
        return ll;
    }
}


I need to transfer count value from getCountings() to getCurrentMonthInfo() and retrieve count variable value in this, Could anyone can solve this plz??
3 Creeks3 Creeks
public List<Lead> getCurrentMonthInfo()
    {
        Integer varFromgetCountings = getCountings();
        List<Lead> ll=Database.query('SELECT Id,Name,Division_Name__c,Title,counting__c '+ 'FROM Lead');
        return ll;
    }

 
sathishkumar periyasamysathishkumar periyasamy
Hi, bit concern with your approach. why you want to have 2 different method and 2 different SOQL query, you can get both result in single method. Please refer below code
 
public List<Lead> getCurrentMonthInfo()
    {
        List<Lead> ll=Database.query('SELECT Id,Name,Division_Name__c,Title,counting__c '+ 'FROM Lead');
 leadcount = ll.size();
// You can use "Size" method to get count
        return ll;
    }

 
RAMANJINEYULU GOGULARAMANJINEYULU GOGULA
Sorry I kept counting__c by mistake, that count in another method retrieves lead counts according to user. That is my concern.
sathishkumar periyasamysathishkumar periyasamy
I don't see any where condition on both SOQL Query. can you please help me to understand you issue more or give you contact info I will call you and resolve your issue?
RAMANJINEYULU GOGULARAMANJINEYULU GOGULA
Trying to develop VF PAGE for displaying these group of names and values

Trying to develop and I need to display leads per each user differently. 
sathishkumar periyasamysathishkumar periyasamy
Do you want to group by Owner or CreatedBy user?
sathishkumar periyasamysathishkumar periyasamy
Please use below query to get lead count by owner id
list<AggregateResult> lstLeadByOwner = [Select count(ID), OwnerID, Owner.Name from Lead group by OwnerId, Owner.Name];

 
RAMANJINEYULU GOGULARAMANJINEYULU GOGULA
This is my VF Page:

<apex:page sidebar="false" controller="salescontroller">
<h1 style="font-size:24px;"><center>SALES REPORT</center></h1>
<table Border='4' BORDERCOLOR='white' width="100%"  cellspacing="4" cellpading="4" >
  <tr align="center" BGCOLOR='#00FFFF'>
             <td align="center" width="5%"><b>Name of the BD</b></td>
             <td align="center" width="5%"><b>Division Name</b></td>
           <!--  <td align="center" width="5%"><b>Sub Team</b></td>-->
             <td align="center" width="5%"><b>Title</b></td>
             <td align="center" width="5%"><b>Total Leads</b></td> 
             <td align="center" width="5%" ><b>Total Deals</b></td>
             <td align="center" width="6%"><b>Payment Amount</b></td> 
 </tr>
 <apex:repeat value="{!CurrentMonthInfo}" var="dat" > 
<tr width="100%" BGCOLOR='#CCFFFF'>

<td align="center"  width="2%"  style="border-top:none;border-right:solid gray 1pt;border-left:none;border-bottom:solid gray 1pt;">
 <apex:outputText value="{!dat.Name}" style="font-style:Arial;font-size:10pt;font-weight:bold;">
 </apex:outputText>
    </td>        
    <td align="center"  width="2%"  style="border-top:none;border-right:solid gray 1pt;border-left:none;border-bottom:solid gray 1pt;">
 <apex:outputText value="{!dat.Division_Name__c}" style="font-style:Arial;font-size:10pt;font-weight:bold;">
 </apex:outputText>
    </td>       
   <td align="center"  width="2%"  style="border-top:none;border-right:solid gray 1pt;border-left:none;border-bottom:solid gray 1pt;">
 <apex:outputText value="{!dat.title}" style="font-style:Arial;font-size:10pt;font-weight:bold;">
 </apex:outputText>
    </td>       
    <apex:repeat value="{!Countings}" var="cts">
<td align="center"  width="2%"  style="border-top:none;border-right:solid gray 1pt;border-left:none;border-bottom:solid gray 1pt;">
 <apex:outputText value="{!cts}" style="font-style:Arial;font-size:10pt;font-weight:bold;">
 </apex:outputText>
    </td>    
    </apex:repeat>  
      <apex:repeat value="{!DealCount}" var="am">
<td align="center"  width="2%"  style="border-top:none;border-right:solid gray 1pt;border-left:none;border-bottom:solid gray 1pt;">
 <apex:outputText value="{!am}" style="font-style:Arial;font-size:10pt;font-weight:bold;">
 </apex:outputText>
    </td>    
    </apex:repeat>  
  
   <td align="center"  width="2%"  style="border-top:none;border-right:solid gray 1pt;border-left:none;border-bottom:solid gray 1pt;">
  <apex:outputText value="{!DealAmount}" style="font-style:Arial;font-size:10pt;">
 </apex:outputText>
    </td>   
   </tr>
</apex:repeat>
 </table>

 <!--
  <apex:form >
  <table>
    <apex:repeat value="{!countings}" var="cts" > 
<tr width="100%" BGCOLOR='#CCFFFF'>

<td align="center"  width="2%"  style="border-top:none;border-right:solid gray 1pt;border-left:none;border-bottom:solid gray 1pt;">
 <apex:outputText value="{!cts}" style="font-style:Arial;font-size:10pt;font-weight:bold;">
 </apex:outputText>
    </td>        </tr>
        </apex:repeat></table>
    </apex:form>  -->
</apex:page>


Controller::

public with sharing class salescontroller 
{

    public String DealAmount { get; set; }
    public string datee='this month';
   public Integer leadcount{ get; set; }
   public String opstage1='WON';
   public String opstage2='Closed';
    public Integer getCountings()
    {
       Integer counts=[SELECT COUNT() FROM Lead];
       leadcount=counts;
        return counts;
    }
    public List<Lead> getCurrentMonthInfo()
    {
        List<Lead> ll=Database.query('SELECT Id,Name,Division_Name__c,Title,counting__c '+ 'FROM Lead ORDER BY Name DESC');
        return ll;
    }
    public List<Opportunity> getDealAmount()
    {
        Opportunity[] opp=Database.query('SELECT Amount FROM Opportunity');
        return opp;
    }
    public Integer getDealCount()
    {
        Integer dealCount=[SELECT COUNT() FROM Opportunity]; // WHERE StageName=:opstage1 AND StageName=:opstage2
        return dealCount;
    }
}


I want to retrieve lead count, deal count and payment amount. 

I think now everyone can get my point easily..
sathishkumar periyasamysathishkumar periyasamy
we got your point - you are blindly pulling all lead and opportunity record with less where condition. This is not best approach. You will get into many limitation when org have more data. see below

1. Heap Size
2. View State
3. SOQL Retrive Row
4. No of line script execution
5. Performance issue

We would recomment to use Standard Report to build many report and combine in to single dashboard (or)  have some filter criteria in your VF page.

If you really want to go for VF page

use below wrapper class to build you logic:
Note : you can use list<wrapperClass> in your VF page.
public class wrapperClass {

public User objUser {get;set;}
Public Decimal dLeadCount {get;set;}
public Decimal dDealAmount {get;set;}
public Decimal dDealCount {get;set;}

public wrapperClass(User objUser, Decimal dLeadCount, Decimal dDealAmount, Decimal dDealCount) {
this.objUser = objUser;
this.dLeadCount = dLeadCount;
this.dDealAmount = dDealAmount;
this.dDealCount = dDealCount;
}
}

 
RAMANJINEYULU GOGULARAMANJINEYULU GOGULA
I just want to put monthly data, so there is no need to receive any user entries.

Could u plz complete code for that by wrapper classses..