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
d.sureshkumar41.33978150573839d.sureshkumar41.33978150573839 

Lead status problem

Hi I want to create one vf page in that i want to show one table with two columns and those are lead owner and ratio of proposed leads by capped leads.

   lead owner                     ratio



proposed is the lead status and capped also lead status .

suppose in a day 10 leads are created in that first owner have  2 are proposed leads and  1 capped lead then we show the ratio of  2/1 for that owner and second owner have 3  proposed leads and 2 capped leads we show the ratio of  3/2 and third owner have 2 proposed leads and 0 capped leads we show the ratio N/A.

      PLZ help me.

raseshtcsraseshtcs
You should follow the below steps
1) Query all the leads created today and store it in map of owner id and list of leads.
2) Loop through the map.keyset and then loop through the leads for that lead owner and calculate the ratio there.
3) put in the ratio and the owner in another map of type id and decimal.
4)Use this map to print the values on the VF page.
d.sureshkumar41.33978150573839d.sureshkumar41.33978150573839

Thank You .I tried with those steps .

raseshtcsraseshtcs
Did it help? If yes then please mark it as a solution for future users
d.sureshkumar41.33978150573839d.sureshkumar41.33978150573839

I queried on all leads and put it in map first is k .

 

the code is

 

public class CLS_submit {

public Lead le{get;set;}
public map<id,string>leadmp{get;set;}
public list<Lead>leadlst{get;set;}
public list<Lead>leadlst1{get;set;}
public list<Lead>leadlst2{get;set;}
public integer i{get;set;}
public integer j{get;set;}
public decimal k{get;set;}

    public CLS_submit(ApexPages.StandardController controller) {
    
    leadmp = new map<id,string>();
    leadlst = new list<Lead>();
    leadlst1 = new list<Lead>();
    leadlst2 = new list<Lead>();
    leadlst =[select OwnerId,name from lead where Lead.Owner.UserRole.id = '00Ed0000000z9IO' AND Status = 'Proposal Sent' AND Lead_ProposalSent_Date__c = today ] ;
    //system.debug('2222'+leadmp);
    
    for(lead L:leadlst)
    {
      leadmp.put(L.OwnerId,L.name);
    
    }
    
    leadlst1= [select Owner.Name from lead where  Lead.Owner.UserRole.id = '00Ed0000000z9IO' AND Status ='MID Submitted' AND MID_Submitted_Lead_Date__c = today ] ;
    //leadlst1.addall(ltdlst);
    //leadlst1.addall(leadlst);
   
   for(lead L:leadlst1)
    {
      leadmp.put(L.OwnerId,L.name);
    
    }
  

 

I cant understand the second step PLZ help me.

raseshtcsraseshtcs
Map<ID,List<Lead>> leadMap = new Map<ID,List<Lead>>();
//We need a map of id and list of leads as there can be multiple leads for an owner.
for(lead L: leadlst1){
if(leadmap.get(L.Ownerid) != null){
List<Lead> leadlst = new List<Lead>();
leadlst = leadmap.get(L.Ownerid);
leadlst.add(L);
leadmap.put(L.Ownerid,leadlst)
}
else{
List<Lead> leadlst1 = new List<Lead>();
leadlst1.add(L);
leadmap.put(L.Ownerid,leadlst1);
}
}
//This way you have map which has lead owner as key and all the leads it owns as value

for(Id i: leadmap.keyset()){
for(Lead l: leadmap.get(i)){
//Logic to calculate the ratio comes here eg u store the ratio in variable x;
ratiomap.put(i,x);//Use this for the VF page
}
}
raseshtcsraseshtcs
ratiomap is a map which has owner id as the key and ratio as the value for that owner
d.sureshkumar41.33978150573839d.sureshkumar41.33978150573839

here the problem is we want to show lead owner name not id then in the map in place of id i take string but it didn,t allow duplicates PLZ resolve this issue.

 

raseshtcsraseshtcs
Please post the code which you used for the string. Basically now you have the id of the owner and the ratio. You can now manipulate that with whatever you need. You can also create a map with the user object instead of id and then use obj.name to get the user name.