• Mathieu Cany
  • NEWBIE
  • 0 Points
  • Member since 2011

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

Hi,

 

Ive created a view like this one (http://imageshack.us/photo/my-images/51/vue1.png/).

As you can see I display all opportunity and there are group by Account Name (A bank In my case).

I'm using the following code for display these informations. (http://blog.sforce.com/sforce/2008/10/group-sum-and-o.html)

 

 

Now I would like to display all my opportunity grouped by another type, nor more related to Account. I would like to group them by Opportunity Owner.  The following sreenshot show that my code doesn't send any information. (http://imageshack.us/content_round.php?page=done&l=img824/1430/vue2m.png&via=mupload&newlp=1)

 

My controller :

 

 

            public class opportunityTotal {
         public Opportunity opportos { get; set; }
         public list <Opportunity> opporto { get; set; }
         public Opportunity total { get; private set; }
         public Opportunity totalparemploye { get; private set; }
         public Opportunity totalparemployepercue { get; private set; }
         public Opportunity account { get; private set; }
         public Opportunity orr { get; set; }
         
        
        
       public opportunityTotal(Opportunity orr) 
 {
    total = new Opportunity(Amount__c = 0);
    totalparemploye = new Opportunity(Commission_to_Sextant__c = 0);
    totalparemployepercue = new Opportunity(Commission_to_Sextant__c = 0); 
    if(orr.Amount__c != null){
    {
        totalparemploye.Commission_to_Sextant__c += orr.Commision_owner_1__c + orr.Amount_commision_2__c + orr.Commission_1_Bis__c;
    }
                              	     
    totalparemployepercue.Commission_to_Sextant__c += orr.Commission_owner_percue__c;
     }

     }
    } 
    
    
    
     public List<OpportunityTotal> getnouvellevueparemploye() {
        List<OpportunityTotal> nouvellevueparemploye = new List<OpportunityTotal>();
        for(Opportunity orr:[select name,Amount,Amount__c, OwnerId, Owner.FirstName, Owner.LastName, Classer_le_dossier_dans_les_historiques__c, LeadSource, Commission_to_Sextant__c, Commision_owner_1__c,	Completion_fees__c,
        							Commission_1_Bis__c, Commission_1_Bis_Paid__c, 	Commission_1_paid_to_owner__c, 	Payed__c, Commision_owner_2__c, Commision_Lead_source__c, 	Amount_charged__c, Amount_commision_2__c, Amount_commision_to_source__c, 	Fee_Paid__c, 	Completion_fee_paid__c,
        							Chiffre_d_affaire_du_dossier__c, CA_realise_du_dossier__c, 	Benefice_du_dossier__c, Befefice_du_dossier_realise__c, StageName, Commission_owner_percue__c
                from Opportunity
                ])  
                 {

        /*   --------1.11------------------------------- AJOUT DES RESULTATS SUR LA 2.00 ------------------1.11---------*/
            nouvellevueparemploye.add(new OpportunityTotal(orr));
        }
        
        /*   --------1.12------------------------------ RETOUR VERS LIST AVEC EN PARAMETRE LA REQUETE ------------------1.12---------*/
        return sortOpportunityTotals(nouvellevueparemploye);
    }
    
    
    
    
private List<OpportunityTotal> sortOpportunityTotals(List<OpportunityTotal> totals) {
        List<OpportunityTotal> returnList = new List<OpportunityTotal>();
        
    
        Map<Decimal, List<OpportunityTotal>> totalMap = new Map<Decimal, List<OpportunityTotal>>();
        
        for(OpportunityTotal t:totals) {
            if(totalMap.get(t.total.amount) == null) {
                totalMap.put(t.total.amount, new List<OpportunityTotal>());            
            }
            totalMap.get(t.total.amount).add(t);
        }

        List<Decimal> keys = new List<Decimal>(totalMap.keySet());
        keys.sort();

        /* Sort puts things in ascending order so for descending iterate over
           the keys backwards. */
        for(Integer i = (keys.size()-1);i >= 0; i--) {
            returnList.addAll(totalMap.get(keys.get(i)));
        }

        return returnList;
    }
           
           
    
    
    

 

 

My VF page

 

 

   
         <apex:pageBlockTable value="{!nouvellevueparemploye}" var="ar">
                <apex:column headerValue="Owner Name" value="{!ar.orr.OwnerId}"/>  
                <apex:column headerValue="Detail">
                <apex:pageBlockTable value="{!ar.orr}" var="o">
                    <apex:column value="{!o.name}"/>
                    <apex:column value="{!o.Fee_Paid__c}"/>
                    <apex:column value="{!o.Amount_charged__c}"/> 
           </apex:pageBlockTable>
            </apex:column>
 
        </apex:pageBlockTable>
        

If there is another way to display infomation that I would like, let me know :).

 

Thanks for your support.

 

Hello.

I've picked an interesting code on internet and used it. It's works well, but when I've modified it like at the code above, i've got an Error Code from Eclipse : "LOOP MUST ITERATE OVER A COLLECTION TYPE: SOBJECT : Opportunity"

 

I tryed the sollution provided here :

http://boards.developerforce.com/t5/Apex-Code-Development/quot-Loop-must-iterate-over-a-collection-type-quot-Error/td-p/178457

 

But it doesn't work. I'm locked In these situation for many hours now. Thanks for your support.

 

 

            public class opportunityTotal {
            	public Opportunity opporto { get; private set; }
         public Opportunity total { get; private set; }
         public Opportunity totalsextant { get; private set; }
        
        public opportunityTotal(Opportunity o) {
        			opporto = o;
                    total = new Opportunity(Amount__c = 0);
                    totalsextant = new Opportunity(Commission_to_Sextant__c = 0);
                    for(Opportunity b:o) {
                        
                            if(b.Amount__c != null){
                            if(b.Classer_le_dossier_dans_les_historiques__c != false){
                            
                                  totalsextant.Commission_to_Sextant__c += b.Commission_to_Sextant__c;
                             }
                 }
            }
        }
    } 
    
    
    
    
    
    
     public List<OpportunityTotal> getnouvellevueparemploye() {
        List<OpportunityTotal> nouvellevueparemploye = new List<OpportunityTotal>();
        for(Opportunity o:[select name,Amount,Amount__c, OwnerId, Owner.FirstName, Owner.LastName, Classer_le_dossier_dans_les_historiques__c, LeadSource, Commission_to_Sextant__c from Opportunity 
                
                where CreatedDate < TODAY])  
                 {

            nouvellevueparemploye.add(new OpportunityTotal(o));
        }
        

        return sortOpportunityTotals(nouvellevueparemploye);
    }
    
    
    
    
     private List<OpportunityTotal> sortOpportunityTotals(List<OpportunityTotal> totals) {
        List<OpportunityTotal> returnList = new List<OpportunityTotal>();
        
    
        Map<Decimal, List<OpportunityTotal>> totalMap = new Map<Decimal, List<OpportunityTotal>>();
        
        for(OpportunityTotal t:totals) {
            if(totalMap.get(t.total.amount) == null) {
                totalMap.put(t.total.amount, new List<OpportunityTotal>());            
            }
            totalMap.get(t.total.amount).add(t);
        }

        List<Decimal> keys = new List<Decimal>(totalMap.keySet());
        keys.sort();

        /* Sort puts things in ascending order so for descending iterate over
           the keys backwards. */
        for(Integer i = (keys.size()-1);i >= 0; i--) {
            returnList.addAll(totalMap.get(keys.get(i)));
        }

        return returnList;
    }

 

 

Hi,

 

I founded a perfect exemple of a tool that i would like to deploy in my salesforce prodution environment. on this link :

http://www.forcetree.com/2010/04/expand-collapse-pageblock-table-columns.html

 

But I Have to test this code provided by the author :

 

public class nestedqueryexample
{
  public List<Account> getaccsandtmember()
  {
      List<Account> accounts = [Select Id,(Select TeamMemberRole, User.Name From Account.AccountTeamMembers), Name, BillingCountry from Account];
      return accounts;
  }
}

 

What is the point to give a code if i can't deploy it easily ? Is It means that the author have written a testing code, and delete it before to put his solution online ?

 

If I have to develop a testing code for a very basic query like that, what will be the appropiate code / test method  for testing it ?

 

Thanks for your support.

 

Hi,

 

I have a very basic problem in the development of my customized page. I would like create a summary table with different information from my environment.  At the beginning i used the Standard controller. But now i would like to have access to data on different area not just Opportunity or Account data. I would like to have information about this both place.

 

So i have decided to create me costumed controller for make a SOQL query and find all information that I need : (Stop me if have already made a mistake)

 

But i don't know how to have an effective Appex Class and 100% coverage code :

 

public class myControllerExtension {
    
      public List<Account> Listaccount()
  {

 

// Exemple of data that i'm looking for

 

      List<Account>  accounts = [Select Id, Name, BillingCountry from Account];
      return accounts;

 

  }
    public static testMethod void Listaccount() {

 

// How i could test this simple Query ? And all next that i'll create

 

}

 

If there is a way to have an access of data from Opportunity and account in the same time without developing my own Controller let me know :)

 

 

A second basic question but i didn't find how to do that, how could I have a sum of all fields in my table?

 

I have already spent a lot of time on guides without success.

 

Thanks a lot

Hello.

I've picked an interesting code on internet and used it. It's works well, but when I've modified it like at the code above, i've got an Error Code from Eclipse : "LOOP MUST ITERATE OVER A COLLECTION TYPE: SOBJECT : Opportunity"

 

I tryed the sollution provided here :

http://boards.developerforce.com/t5/Apex-Code-Development/quot-Loop-must-iterate-over-a-collection-type-quot-Error/td-p/178457

 

But it doesn't work. I'm locked In these situation for many hours now. Thanks for your support.

 

 

            public class opportunityTotal {
            	public Opportunity opporto { get; private set; }
         public Opportunity total { get; private set; }
         public Opportunity totalsextant { get; private set; }
        
        public opportunityTotal(Opportunity o) {
        			opporto = o;
                    total = new Opportunity(Amount__c = 0);
                    totalsextant = new Opportunity(Commission_to_Sextant__c = 0);
                    for(Opportunity b:o) {
                        
                            if(b.Amount__c != null){
                            if(b.Classer_le_dossier_dans_les_historiques__c != false){
                            
                                  totalsextant.Commission_to_Sextant__c += b.Commission_to_Sextant__c;
                             }
                 }
            }
        }
    } 
    
    
    
    
    
    
     public List<OpportunityTotal> getnouvellevueparemploye() {
        List<OpportunityTotal> nouvellevueparemploye = new List<OpportunityTotal>();
        for(Opportunity o:[select name,Amount,Amount__c, OwnerId, Owner.FirstName, Owner.LastName, Classer_le_dossier_dans_les_historiques__c, LeadSource, Commission_to_Sextant__c from Opportunity 
                
                where CreatedDate < TODAY])  
                 {

            nouvellevueparemploye.add(new OpportunityTotal(o));
        }
        

        return sortOpportunityTotals(nouvellevueparemploye);
    }
    
    
    
    
     private List<OpportunityTotal> sortOpportunityTotals(List<OpportunityTotal> totals) {
        List<OpportunityTotal> returnList = new List<OpportunityTotal>();
        
    
        Map<Decimal, List<OpportunityTotal>> totalMap = new Map<Decimal, List<OpportunityTotal>>();
        
        for(OpportunityTotal t:totals) {
            if(totalMap.get(t.total.amount) == null) {
                totalMap.put(t.total.amount, new List<OpportunityTotal>());            
            }
            totalMap.get(t.total.amount).add(t);
        }

        List<Decimal> keys = new List<Decimal>(totalMap.keySet());
        keys.sort();

        /* Sort puts things in ascending order so for descending iterate over
           the keys backwards. */
        for(Integer i = (keys.size()-1);i >= 0; i--) {
            returnList.addAll(totalMap.get(keys.get(i)));
        }

        return returnList;
    }

 

 

Hi,

 

I have a very basic problem in the development of my customized page. I would like create a summary table with different information from my environment.  At the beginning i used the Standard controller. But now i would like to have access to data on different area not just Opportunity or Account data. I would like to have information about this both place.

 

So i have decided to create me costumed controller for make a SOQL query and find all information that I need : (Stop me if have already made a mistake)

 

But i don't know how to have an effective Appex Class and 100% coverage code :

 

public class myControllerExtension {
    
      public List<Account> Listaccount()
  {

 

// Exemple of data that i'm looking for

 

      List<Account>  accounts = [Select Id, Name, BillingCountry from Account];
      return accounts;

 

  }
    public static testMethod void Listaccount() {

 

// How i could test this simple Query ? And all next that i'll create

 

}

 

If there is a way to have an access of data from Opportunity and account in the same time without developing my own Controller let me know :)

 

 

A second basic question but i didn't find how to do that, how could I have a sum of all fields in my table?

 

I have already spent a lot of time on guides without success.

 

Thanks a lot