• etechcareers
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 59
    Questions
  • 39
    Replies

Hi everyone:

   Everything is great with my testmethod with the exception that it is not picking up Page Reference Query()???

I cant figure it out:

Here is my apex controller for Page Reference Query();It picks up until If(level=='A') but will not go into aggregate result or passed that... i tried everything in my test method please help.

thanks

Happy holidays

public PageReference query() { 
Date Lastmonthfirst;
Date selectedDate =  Date.Today(); //Give your date
Lastmonthfirst = selectedDate.toStartOfMonth().addMonths(-1);
     
    List<Compensation__c>  delmarker = new List<Compensation__c>(); 

    delmarker=[select id from Compensation__c where Date_ran__c =LAST_MONTH];

    
    for(Compensation__c sm:delmarker){
        delete sm;
    }  
       

  If (Level=='AA'){     
  AggregateResult[] groupedResults = [SELECT Ownerid, Count(Id) ce
                                     FROM Opportunity Where Comp__c=False  
                                     AND CloseDate=LAST_MONTH 
                                     AND StageName = 'Closed Won'
                                     GROUP BY Ownerid];  

                                      
    queryResults = new List<GrossHolder>();
    for (AggregateResult ar : groupedResults)  {
        GrossHolder myObject = new GrossHolder();
            myObject.TotalGross = (Integer) ar.get('ce');
            Gross = myObject.TotalGross;
            myObject.compid = String.valueOf(ar.get('Ownerid'));
            AAid = myObject.compid;
            getWithdrawn(AAid);
            getWithdrawnT(AAid);
            getCustomers(AAid);
/*****************************INSERT COMP**********************************************************************/

            Compensation__c cmp = new Compensation__c();
            cmp.Name__c = AAid;
            cmp.Comp_Plan__c ='AA';
            cmp.Total_Gross__c = Gross;
            cmp.Date_ran__c = Lastmonthfirst;
                
               if(AAWid!=AAid){
                    cmp.Total_Withdrawn__c = 0;
                }
                else{
                    cmp.Total_Withdrawn__c = Withdrawn;
                    if(cmp.Total_Withdrawn__c == null){
                        cmp.Total_Withdrawn__c = 0;
                    }                    
                }
                 
                if(AATid!=AAid){
                    cmp.Total_Transfers__c = 0;
                }
                else{
                    cmp.Total_Transfers__c = Transferred;
                    if(cmp.Total_Transfers__c == null){
                        cmp.Total_Transfers__c = 0;
                    }
               } 
               
                if(AACSid!=AAid){
                    cmp.Total_Customers__c = 0;
                }
                else{
                    cmp.Total_Customers__c = Customers;
                    if(cmp.Total_Customers__c == null){
                        cmp.Total_Customers__c = 0;
                    }
               }                                
                insert cmp;
        queryResults.add(myObject); 
        }
        }
        return null;
    }

 Here is my test class:

@isTest(SeeAllData=true)
private class compensationreport_TestMethod // Name of the test class, Can be any name
{         
    static testmethod void compensationreport_TestMethod(){   // Name of the test method. Must be the same as the class name      
        Date Lastmonthfirst;
        Date selectedDate =  Date.Today(); //Give your date
        Lastmonthfirst = selectedDate.toStartOfMonth().addMonths(-1);
        //Set up user  
        User u1 = [SELECT Id FROM User WHERE Alias='ZishanR'];
        System.runAs(u1) {
        Compensation__c cc = new Compensation__c
            (
                Total_Gross__c = 120, 
                Total_Withdrawn__c = 10,
                Total_Transfers__c = 0,
                Comp_Plan__c = 'AA',
                Total_Customers__c = 127,
                Name__c = u1.Id,
                Date_ran__c = Lastmonthfirst
            );
            insert cc;
        Account a = new Account();
            a.firstName = 'lisa';
            a.Lastname = 'stevenlee';
            a.PersonLeadSource = 'Other';
            a.PersonEmail = 'choosepros123@iintest.com';
            a.PersonBirthdate = date.newinstance(1974,10,11);
            a.Birthday__c = date.newinstance(1974,10,11);
            a.CreatedDate = Lastmonthfirst;
            a.ownerid = u1.id;
            a.BillingStreet = '128 new st';
            a.BillingCity = 'New York';
            a.BillingState = 'NY';
            a.BillingCountry = 'USA';
            a.BillingPostalCode = '10061';
        insert a;
        
        System.Debug('yes' + a.CreatedDate + a.id + a.Ownerid + a.Owner.Level__c);
        
        Opportunity o = new Opportunity();
            o.Accountid = a.id;
            o.Name = 'IInTest - HTCP Jan 2012';
            o.CloseDate = Lastmonthfirst;
            o.StageName = 'Closed Won';
            o.Comp__c = False;
            o.LeadSource = 'Natural Healers';
            o.Type = 'Re-enrollment';
            
        
        
        Opportunity oWT = new Opportunity();
            oWT.Accountid = a.id;
            owT.Name = 'IINTestWT - HTCP Jan 2012';
            owT.CloseDate = Lastmonthfirst;
            owT.Withdrawn_Date__c = Lastmonthfirst; 
            owT.StageName = 'Closed Won';
            owT.Withdrawn__c = True;
            owT.LeadSource = 'Natural Healers';
            owT.Withdrawal_Status__c = 'Transferred to DL';
            owT.Refunded_Amount__c = 3100;
            owT.Withdrawal_Fee__c = 100;
            
        
        Opportunity oW2 = new Opportunity();
            oW2.Accountid = a.id;
            ow2.Name = 'IINTestW2 - HTCP Jan 2012';
            ow2.CloseDate = Lastmonthfirst;
            ow2.Withdrawn_Date__c = Lastmonthfirst; 
            ow2.StageName = 'Closed Won';
            ow2.Withdrawn__c = True;
            ow2.LeadSource = 'Natural Healers';
            ow2.Withdrawal_Status__c = 'Withdrawn';
            ow2.Refunded_Amount__c = 3100;
            ow2.Withdrawal_Fee__c = 100;
            ow2.Withdrawal_Reason_Further_Detail__c = 'this is my test';

        Account ac = new Account();
            ac.firstName = 'lisa';
            ac.Lastname = 'stevenleered';
            ac.PersonLeadSource = 'Other';
            ac.PersonEmail = 'choosepros1234@iintest.com';
            ac.PersonBirthdate = date.newinstance(1974,10,11);
            ac.Birthday__c = date.newinstance(1974,10,11);
            ac.CreatedDate = Lastmonthfirst;
            ac.ownerid = u1.id;
            ac.BillingStreet = '127 new st';
            ac.BillingCity = 'New York';
            ac.BillingState = 'NY';
            ac.BillingCountry = 'USA';
            ac.BillingPostalCode = '10061';
            
        //Use the PageReference Apex class to instantiate a page
     
        compensationreport testcls = new compensationreport();   // Initialize variable for original class 
                
        
        Test.startTest();
        testcls = new compensationreport(); 
        String AAid = u1.id;  
        System.Debug('URL' + Page.comp_run.getURL());
 
        //system.assertEquals(Expected,actual);       
        insert o;
        insert owT;
        insert ow2;
        
        // Call Function of Original class  
        Opportunity oop = [Select ownerid, id from Opportunity where id=: o.id];     
        testcls.getGrossHolder(oop.ownerid);
        testcls.getWithdrawn(oop.ownerid);                        
        testcls.getWithdrawnT(oop.ownerid);


        insert ac; 
        Account abc = [Select Ownerid,id from Account where id=:ac.id];
        testcls.getCustomers(abc.Ownerid);
        
        testcls.query();
         Compensation__c cmp = new Compensation__c();
            cmp.Name__c = AAid;
            cmp.Comp_Plan__c ='AA';
            cmp.Total_Gross__c = 1;
            cmp.Date_ran__c = Lastmonthfirst;
            cmp.Total_Withdrawn__c = 1;
            cmp.Total_Transfers__c = 1;
            cmp.Total_Customers__c = 1;
        insert cmp;
        Test.stopTest();

    }    
    }
}

 

Hi I keep getting these warnings:

Caused the following Apex resource warnings:

Number of SOQL queries: 95 out of 100

 

My Class is simple as this:How can I avoid this warning or write it any other way?Thanks

Z

 

public class compensationreport{
    public string AAid{get;set;}
    public string AAWid{get;set;}
    public string AATid{get;set;}
    public string AACSid{get;set;}
    public string CompName{get;set;}
    public Integer Gross{get;set;}
    public Integer Withdrawn{get;set;}
    public Integer Transferred{get;set;}
    public Integer Customers{get;set;}
    public String Level { get { return Level ;} set { Level=value ; } } 

    public List<GrossHolder> queryResults{ get; set; }  
    public class GrossHolder {       
        public String AAName {get; set;}
        public Integer TotalGross {get; set;}
        public String compid{get;set;}    
        public GrossHolder(){}
    }
    
/*******************************************TOTAL Withdrawn******************************************************************************************/

    public List<WithdrawnHolder> queryResultsW{ get; set; }  
    public class WithdrawnHolder {
        public Integer TotalW {get; set;}
        public String AANameW {get; set;}
        public String aax {get;set;}
        public WithdrawnHolder(){}
    }
 
    public String getWithdrawn(String id){


                            
    AggregateResult[] groupedResults = [SELECT Ownerid,Count(Id) ce 
                            FROM Opportunity Where 
                            Withdrawn__c = True 
                            AND StageName = 'Closed Won' 
                            AND Withdrawal_Status__c ='Withdrawn' 
                            AND Withdrawn_Date__c = LAST_MONTH
                            AND Ownerid=:id 
                            AND (NOT Name Like '%COMP%')
                            GROUP BY Ownerid]; 
        
    queryResultsW = new List<WithdrawnHolder>();
    
    for (AggregateResult ar : groupedResults)  {
        WithdrawnHolder myObject = new WithdrawnHolder();
            myObject.aax = String.valueOf(ar.get('Ownerid'));
            AAWid =  myObject.aax;
            myObject.TotalW = (Integer) ar.get('ce');
        Withdrawn = myObject.TotalW ;    
        queryResultsW.add(myObject); 
    }
        return null;    
}  
/*******************************************TOTAL TRANSFERRED******************************************************************************************/
    public List<WithdrawnHolderT> queryResultsWT{ get; set; }  

    public class WithdrawnHolderT {

        public Integer TotalWT {get; set;}
         public String AANameWT {get; set;}
         public String aaxT {get;set;}
    public WithdrawnHolderT(){
    }
    }
 
    public String getWithdrawnT(String id){

             
    AggregateResult[] groupedResults = [SELECT Ownerid,Count(Id) ce 
                            FROM Opportunity Where 
                            Withdrawn__c = True 
                            AND StageName = 'Closed Won' 
                            AND Withdrawal_Status__c = 'Transferred to DL' 
                            AND Withdrawn_Date__c = LAST_MONTH  
                            AND Ownerid=:id 
                            AND (NOT Name Like '%COMP%')
                            GROUP BY Ownerid];         
        
    queryResultsWT = new List<WithdrawnHolderT>();
    
    for (AggregateResult ar : groupedResults)  {
        WithdrawnHolderT myObject = new WithdrawnHolderT();
        myObject.aaxT = String.valueOf(ar.get('Ownerid'));
        AATid =  myObject.aaxT;
        myObject.TotalWT = (Integer) ar.get('ce');
        Transferred = myObject.TotalWT ;
    
    queryResultsWT.add(myObject); 
      
    }
    return null;    
    }  
/*******************************************TOTAL CUSTOMERS******************************************************************************************/    
    public List<customers> queryResultscs{ get; set; }  
    public class customers {

        public Integer TotalCS {get; set;}
         public String AANameCS {get; set;}
         public String aaxCS {get;set;}
    public customers(){
    }
    }
 
    public String getCustomers(String id){


    
    AggregateResult[] groupedResults = [SELECT Ownerid,Count(Id) ce 
                                        FROM Account 
                                        Where Owner.Level__c = 'AA' 
                                        AND Ownerid=:id AND CreatedDate = LAST_MONTH
                                        GROUP BY Ownerid]; 
                    
    queryResultscs = new List<customers>();
    
    for (AggregateResult ar : groupedResults)  {
        customers myObject = new customers();
        myObject.aaxCS = String.valueOf(ar.get('Ownerid'));
        AACSid =  myObject.aaxCS;
        myObject.TotalCS = (Integer) ar.get('ce');
        Customers = myObject.TotalCS ;
    
    queryResultscs.add(myObject); 
      
    }
    return null;    
    }                               
/*******************************************Actual******************************************************************************************/     
public PageReference query() { 
Date Lastmonthfirst;
Date Lastmonthend;

Date selectedDate =  Date.Today(); //Give your date
Date firstDate = selectedDate.toStartOfMonth();
Date lastDate = firstDate.addDays(date.daysInMonth(selectedDate.year() , selectedDate.month())  - 1);
system.debug(firstDate  + ' **** ' +lastDate );
//******************************************************************************************************
Lastmonthfirst = selectedDate.toStartOfMonth().addMonths(-1);
Lastmonthend = Lastmonthfirst.addDays(date.daysInMonth(Lastmonthfirst.year() , Lastmonthfirst.month())  - 1);
system.debug(Lastmonthfirst  + ' **** ' +Lastmonthend );

     
    List<Compensation__c>  delmarker = new List<Compensation__c>(); 

    delmarker=[select id from Compensation__c where Date_ran__c =LAST_MONTH];

    
    for(Compensation__c sm:delmarker){
        delete sm;
    }  
       
       
        
  If (Level=='AA'){
       
              AggregateResult[] groupedResults = [SELECT Ownerid, Count(Id) ce
                                                 FROM Opportunity Where Comp__c=False  
                                                 AND CloseDate=LAST_MONTH 
                                                 AND StageName = 'Closed Won'
                                                 GROUP BY Ownerid];  

                                      
    queryResults = new List<GrossHolder>();
    for (AggregateResult ar : groupedResults)  {
        GrossHolder myObject = new GrossHolder();
            myObject.TotalGross = (Integer) ar.get('ce');
            myObject.compid = String.valueOf(ar.get('Ownerid'));
            AAid = myObject.compid;
            
            getWithdrawn(AAid);
            getWithdrawnT(AAid);
            getCustomers(AAid);
/*****************************INSERT COMP**********************************************************************/

            Compensation__c cmp = new Compensation__c();
            cmp.Name__c = myobject.compid;
            cmp.Comp_Plan__c ='AA';
            cmp.Total_Gross__c = myObject.TotalGross;
            cmp.Date_ran__c = Lastmonthfirst;
                
               if(AAWid!=AAid){
                    cmp.Total_Withdrawn__c = 0;
                }
                else{
                    cmp.Total_Withdrawn__c = Withdrawn;
                    if(cmp.Total_Withdrawn__c == null){
                        cmp.Total_Withdrawn__c = 0;
                    }                    
                }
                 
                if(AATid!=AAid){
                    cmp.Total_Transfers__c = 0;
                }
                else{
                    cmp.Total_Transfers__c = Transferred;
                    if(cmp.Total_Transfers__c == null){
                        cmp.Total_Transfers__c = 0;
                    }
               } 
               
                if(AACSid!=AAid){
                    cmp.Total_Customers__c = 0;
                }
                else{
                    cmp.Total_Customers__c = Customers;
                    if(cmp.Total_Customers__c == null){
                        cmp.Total_Customers__c = 0;
                    }
               }                                
                insert cmp;
        queryResults.add(myObject); 
        }
        }
        return null;
    } 
}

 

Hi Everyone:

   I do not understand why is my getCustomers method timing out to too many SOQL Queries?? When I remove the method it works...

Here is the error on my log:

Class.compensationreport.getCustomers: line 148, column 1

Class.compensationreport.query: line 227, column 1

 

Please help....and I keep getting Apex Governor Limit Warning that states Number of SOQL queries: 77 out of 100???

Thanks

Z

 

public class compensationreport{
    public string AAid{get;set;}
    public string AAWid{get;set;}
    public string AATid{get;set;}
    public string AACSid{get;set;}
    public string CompName{get;set;}
    public Integer Gross{get;set;}
    public Integer Withdrawn{get;set;}
    public Integer Transferred{get;set;}
    public Integer Customers{get;set;}
    public String Level { get { return Level ;} set { Level=value ; } } 
    public String Monthrun { get { return Monthrun ;} set { Monthrun=value ; } }    
    
    public List<GrossHolder> queryResults{ get; set; }  
    public class GrossHolder {       
        public String AAName {get; set;}
        public Integer TotalGross {get; set;}
        public String compid{get;set;}    
        public GrossHolder(){}
    }
    
/*******************************************TOTAL Withdrawn******************************************************************************************/

    public List<WithdrawnHolder> queryResultsW{ get; set; }  
    public class WithdrawnHolder {
        public Integer TotalW {get; set;}
        public String AANameW {get; set;}
        public String aax {get;set;}
        public WithdrawnHolder(){}
    }
 
    public String getWithdrawn(String id){
    List<SObject> qrystringW = new List<SObject>();
        if(Monthrun=='THIS_MONTH'){
            qrystringW = [SELECT Ownerid,Count(Id) ce 
                            FROM Opportunity Where 
                            Withdrawn__c = True 
                            AND StageName = 'Closed Won' 
                            AND Withdrawal_Status__c ='Withdrawn' 
                            AND Withdrawn_Date__c = THIS_MONTH
                            AND Ownerid=:id 
                            AND (NOT Name Like '%COMP%')
                            GROUP BY Ownerid]; 
        }
        else {
            qrystringW = [SELECT Ownerid,Count(Id) ce 
                            FROM Opportunity Where 
                            Withdrawn__c = True 
                            AND StageName = 'Closed Won' 
                            AND Withdrawal_Status__c ='Withdrawn' 
                            AND Withdrawn_Date__c = LAST_MONTH
                            AND Ownerid=:id 
                            AND (NOT Name Like '%COMP%')
                            GROUP BY Ownerid]; 
        
        }
                            
    AggregateResult[] groupedResults = qrystringW; 
        
    queryResultsW = new List<WithdrawnHolder>();
    
    for (AggregateResult ar : groupedResults)  {
        WithdrawnHolder myObject = new WithdrawnHolder();
            myObject.aax = String.valueOf(ar.get('Ownerid'));
            AAWid =  myObject.aax;
            myObject.TotalW = (Integer) ar.get('ce');
        Withdrawn = myObject.TotalW ;    
        queryResultsW.add(myObject); 
    }
        return null;    
}  
/*******************************************TOTAL TRANSFERRED******************************************************************************************/
    public List<WithdrawnHolderT> queryResultsWT{ get; set; }  

    public class WithdrawnHolderT {

        public Integer TotalWT {get; set;}
         public String AANameWT {get; set;}
         public String aaxT {get;set;}
    public WithdrawnHolderT(){
    }
    }
 
    public String getWithdrawnT(String id){
    List<SObject> qrystringT = new List<SObject>();
        if(Monthrun=='THIS_MONTH'){
            qrystringT = [SELECT Ownerid,Count(Id) ce 
                            FROM Opportunity Where 
                            Withdrawn__c = True 
                            AND StageName = 'Closed Won' 
                            AND Withdrawal_Status__c = 'Transferred to DL' 
                            AND Withdrawn_Date__c = THIS_MONTH  
                            AND Ownerid=:id 
                            AND (NOT Name Like '%COMP%')
                            GROUP BY Ownerid]; 
         }
         else {
              qrystringT = [SELECT Ownerid,Count(Id) ce 
                            FROM Opportunity Where 
                            Withdrawn__c = True 
                            AND StageName = 'Closed Won' 
                            AND Withdrawal_Status__c = 'Transferred to DL' 
                            AND Withdrawn_Date__c = LAST_MONTH  
                            AND Ownerid=:id 
                            AND (NOT Name Like '%COMP%')
                            GROUP BY Ownerid];        
         }                   
    AggregateResult[] groupedResults = qrystringT; 
        
    queryResultsWT = new List<WithdrawnHolderT>();
    
    for (AggregateResult ar : groupedResults)  {
        WithdrawnHolderT myObject = new WithdrawnHolderT();
        myObject.aaxT = String.valueOf(ar.get('Ownerid'));
        AATid =  myObject.aaxT;
        myObject.TotalWT = (Integer) ar.get('ce');
        Transferred = myObject.TotalWT ;
    
    queryResultsWT.add(myObject); 
      
    }
    return null;    
    }  
/*******************************************TOTAL CUSTOMERS******************************************************************************************/    
    public List<customers> queryResultscs{ get; set; }  
    public class customers {

        public Integer TotalCS {get; set;}
         public String AANameCS {get; set;}
         public String aaxCS {get;set;}
    public customers(){
    }
    }
 
    public String getCustomers(String id){
    List<SObject> qrystringc = new List<SObject>();
        if(Monthrun=='THIS_MONTH'){
            qrystringc = [SELECT Ownerid,Count(Id) ce 
                            FROM Account 
                            Where Owner.Role_Name__c Like '%Advisor%' 
                            AND Ownerid=:id AND CreatedDate = THIS_MONTH
                            GROUP BY Ownerid];
        }
        else{
            qrystringc = [SELECT Ownerid,Count(Id) ce 
                            FROM Account 
                            Where Owner.Role_Name__c Like '%Advisor%' 
                            AND Ownerid=:id AND CreatedDate = LAST_MONTH
                            GROUP BY Ownerid];        
        }
    
    
    AggregateResult[] groupedResults = qrystringc;  
        
    queryResultscs = new List<customers>();
    
    for (AggregateResult ar : groupedResults)  {
        customers myObject = new customers();
        myObject.aaxCS = String.valueOf(ar.get('Ownerid'));
        AACSid =  myObject.aaxCS;
        myObject.TotalCS = (Integer) ar.get('ce');
        Customers = myObject.TotalCS ;
    
    queryResultscs.add(myObject); 
      
    }
    return null;    
    }                               
/*******************************************Actual******************************************************************************************/     
public PageReference query() { 
Date Lastmonthfirst;
Date Lastmonthend;

Date selectedDate =  Date.Today(); //Give your date
Date firstDate = selectedDate.toStartOfMonth();
Date lastDate = firstDate.addDays(date.daysInMonth(selectedDate.year() , selectedDate.month())  - 1);
system.debug(firstDate  + ' **** ' +lastDate );
//******************************************************************************************************
Lastmonthfirst = selectedDate.toStartOfMonth().addMonths(-1);
Lastmonthend = Lastmonthfirst.addDays(date.daysInMonth(Lastmonthfirst.year() , Lastmonthfirst.month())  - 1);
system.debug(Lastmonthfirst  + ' **** ' +Lastmonthend );

     
    List<Compensation__c>  delmarker = new List<Compensation__c>(); 
    If(Monthrun=='THIS_MONTH'){
        delmarker=[select id from Compensation__c where Date_ran__c =THIS_MONTH];
    }
    else{delmarker=[select id from Compensation__c where Date_ran__c =LAST_MONTH];}
    
    for(Compensation__c sm:delmarker){
        delete sm;
    }  
       
    List<SObject> qrystringf =new List<SObject>();
        if(Monthrun=='THIS_MONTH'){
            qrystringf=[SELECT Ownerid, Count(Id) ce
                        FROM Opportunity Where Comp__c=False  
                        AND CloseDate=THIS_MONTH 
                        AND StageName = 'Closed Won'
                        GROUP BY Ownerid];
    }
    else
    {
            qrystringf=[SELECT Ownerid, Count(Id) ce
                        FROM Opportunity Where Comp__c=False  
                    AND CloseDate=LAST_MONTH 
    AND StageName = 'Closed Won'
    GROUP BY Ownerid];           
    }         
  If (Level=='AA'){
       
              AggregateResult[] groupedResults = qrystringf; 

                                      
    queryResults = new List<GrossHolder>();
    for (AggregateResult ar : groupedResults)  {
        GrossHolder myObject = new GrossHolder();
            myObject.TotalGross = (Integer) ar.get('ce');
            myObject.compid = String.valueOf(ar.get('Ownerid'));
            AAid = myObject.compid;
            
            getWithdrawn(AAid);
            getWithdrawnT(AAid);
            getCustomers(AAid);
/*****************************INSERT COMP**********************************************************************/

            Compensation__c cmp = new Compensation__c();
            cmp.Name__c = myobject.compid;
            cmp.Comp_Plan__c ='AA';
            cmp.Total_Gross__c = myObject.TotalGross;
            IF(Monthrun=='THIS_MONTH'){            
                cmp.Date_ran__c = date.TODAY();
            }
            else{
                cmp.Date_ran__c = Lastmonthfirst;
            }
                
               if(AAWid!=AAid){
                    cmp.Total_Withdrawn__c = 0;
                }
                else{
                    cmp.Total_Withdrawn__c = Withdrawn;
                    if(cmp.Total_Withdrawn__c == null){
                        cmp.Total_Withdrawn__c = 0;
                    }                    
                }
                 
                if(AATid!=AAid){
                    cmp.Total_Transfers__c = 0;
                }
                else{
                    cmp.Total_Transfers__c = Transferred;
                    if(cmp.Total_Transfers__c == null){
                        cmp.Total_Transfers__c = 0;
                    }
               } 
               
                if(AACSid!=AAid){
                    cmp.Total_Customers__c = 0;
                }
                else{
                    cmp.Total_Customers__c = Customers;
                    if(cmp.Total_Customers__c == null){
                        cmp.Total_Customers__c = 0;
                    }
               }                                
                insert cmp;
        queryResults.add(myObject); 
        }
        }
        return null;
    } 
}

 

HI:

   I have a table with bonus amounts in it depending on Comp_Plan

If the Level of the Person is 100 let's say and in the CompPlan table a level of 100 is $2000, and another level of a person is 60 and bonus is $1000...

My code is picking up the $1000 instead of $2000 when the level of that person is 120...

trigger bonusAmount on Compensation__c (before insert,before update) {

    List<Compensation__c> pu = new List<Compensation__c>();

    

         
         for(Compensation__c o: Trigger.New){
             List<Comp_Plan__c> accountWithOpptys = [Select id, Comp__c,Goal__c,Category__c,Goal_Amount__c,Level__c from Comp_Plan__c where Team_Goal__c=True AND Comp__c =:o.Comp_plan__c];            
            System.Debug('***'+accountWithOpptys.size() + o.Comp_Plan__c); //This is correct brings up 8 records for Comp_Plan__c=AA and the levels from 30-100 with the Goal_Amount...
 
            if(o.NELevel__c >= 100){ //In the record I am editing the level is 120 which is greater then 100 but the person should get 2500 yet it is getting 1000 which the 1000 is for level 60????
                 o.NEBonus__c = accountWithOpptys[0].Goal_Amount__c;            
            pu.add(o);
            }
        }
}

 Hope this helps please...

thanks

Z

 

Hi, i am trying to get a user picklist going of active users. i keep getting the following error:

Collection size 1,287 exceeds maximum size of 1,000.

 

public with sharing class Userform{

    public Userform(ApexPages.StandardController controller) {

    }

  public String val {get;set;}
 
  public List<SelectOption> getName()
  {
    List<User> gd = [Select id, name from User where IsActive=true];     
    List<SelectOption> options = new List<SelectOption>();
    
    for(User f : gd)
    {
       options.add(new SelectOption(f.id,f.Name));
    }
    return options;
   }

}

 

<apex:page standardcontroller="User" extensions="Userform">
<apex:form>
      <apex:SelectList value="{!val}" size="1">         
      <apex:selectOptions value="{!Name}"></apex:selectOptions>
       </apex:SelectList>
</apex:form>        
</apex:page>

 Where am i going wrong....

thanks

 


Hi I have a trigger that would insert any changes into an object...

but I need to know instead of me writing every field and stating if null then...

Here is my code:

 

if (Trigger.old[0].Email != null && Trigger.old[0].LastName != null && (
    Trigger.old[0].Operations__c != Trigger.new[0].Operations__c ||
    Trigger.old[0].Interests__c != Trigger.new[0].Interests__c ||
    Trigger.old[0].Details__c != Trigger.new[0].Details__c ||
    Trigger.old[0].Int__c != Trigger.new[0].Int__c ||
    Trigger.old[0].Contact_Status__c != Trigger.new[0].Contact_Status__c )) {

 

Anyhelp please would help...

 

Hi:

   Does anyone know what is wrong with my statement:

 

public class Productff {

//Define your variables
public class OppStageHolder {
    public String OPP {get; set;}
    public Integer TTL_Opp {get; set;}
//Empty Array    
public OppStageHolder (){}
}
//Results will be placed within this List
public List queryResults {get;set;}

//Your Page
public PageReference TTL() {

AggregateResult[] groupedResults = [SELECT Product_Name__c, Sum(TotalPrice) ce FROM OpportunityLineItem 
                                    GROUP BY Product_Name__c];  
System.Debug('zzavg ' + groupedResults.size());
//Define your List
queryResults = new List();

for (AggregateResult ard : groupedResults)  {    
    OppStageHolder myObject = new OppStageHolder();    
    myObject.OPP = String.valueOf(ard.get('Product_Name__c'));    
    myObject.TTL_Opp = (Integer) ard.get('ce');         
    queryResults.add(myObject);    
}
return Page.TTL;
}


}

 

 

Hi I keep getting this error:

Constructor not defined: [ProductBreakdown.OpportunityTotal].<Constructor>(SOBJECT:OpportunityLineItem)

What is wrong with my code?

 

   public List<OpportunityTotal> getOpportunityTotals() {
        List<OpportunityTotal> OpportunityTotals = new List<OpportunityTotal>();
        for(OpportunityLineItem o:[SELECT Id,  
                            TotalPrice, Product_Name__c, Opportunity.Id, 
                            Opportunity.Name, Opportunity.StageName,
                            Opportunity.Accountid, Opportunity.Amount 
                            FROM OpportunityLineItem Where 
                            Opportunity.StageName='Closed Won' And 
                            Opportunity.Account.id='001Q000000Js7pP' 
                            ])
            {
                OpportunityTotals.add(new OpportunityTotal(o));
            }
        return sortOpportunityTotals(OpportunityTotals);
    }

 Thanks

 

 

<apex:outputField value="{!a.total.TotalPrice}"/>

 

What is wrong with this?

 

Because I am getting this: Error:Currency fields on entities with effective dated currency are not supported???

Hi:

   My query does not work:

 

SELECT Id, ActivityDate, Status, Who.MailingCity, Who.MailingState, Who.Email FROM Task

 What is wrong with it? Please advise...

I am guessing Who.MailingCity and Who.MailingState but Why???

 

Hi everyone:

   Basically I have a workflow rule that fires off when a new record is created and the criteria is met. Criteria pretty simple, if Amount is not equal NULL then it is a field update.

 

The thing is, if the users hit Clone then I do not want the field to update through the workflow rule.

 

The users when they clone something, they would like to place in a sales rep id and not have it over written by the workflow rule....

 

Anyone, has any suggestions?

 

Thanks

Hi everyone:

   I enabled chatter in my org, now my users can not place comments from either the home page or in there user profile. They keep getting an error message stating:

you must be a System Administrator to edit this record????

 

Anyone know what else I would have to turn on?

 

Thanks

Hi all:

   Instead of nulls in SOQL query for date values what should we use?

For example:

 

Account acct =[Select name from Account where xdate__c=NULL];

 I heard that nulls for date values are not good in SOQL Queries?

 

Hi:

   What is this error:

System.LimitException: Too
many query rows: 725 stacktrace

What is wrong with my method here... this is where I am getting the error.

 

 

public List<Opportunity> getOpportunities(){
      
        opportunities = [Select o.name, o.CloseDate, 
            (Select x_CC__c From cv__R00N40000001X8re__r) 
        FROM Opportunity o 
        WHERE x_Date__c = NULL 
        AND StageName = 'Received' ORDER BY CloseDate];

      return opportunities;
    }

 

 

Hi:

   Has anyone done a web-to-case with attachment utilizing Webservices API through .NET...

Here are the following steps that I have done:

 

1. Wrote Global Webservice Apex Class

2. Download Enterprise WSDL

 

I do not know how to write connection in .NET to salesforce...

Can someone give me an example please....

I need to connect and pass the variables over to the class.. which is my other thing I do not know how to call the webservice class through .NET to SFDC...

 

Thanks

 

I am building a search VF page and was wondering does the apex code take in account for the profile being used. Like for me it is bringing back every account no matter what recordtype. of course I am admin.

 

But would that be the same as a user. Would it restrict access to that user if they click on it.

 

Is there a way to make the code, search on based on the profile/recordtype?

 

Thanks

 

Hi:

   Has anyone try to do a web-to-case and within the form give the ability of uploading an attachment to that case???

I can not seem to figure it out?

Any thoughts???

thanks

hi :

   I love testunits :)

How do you call the following in a test unit:

 

  public String rtps {get{return rtps;} set{ rtps = value;}}

 

Thank you

 

hi the following is the page reference in my apex controller:

 

public PageReference step3() {
    //Contribution RecordType
    if(rtps=='012S0000000D3Q5IAK'){
        return Page.znewopptystep_Contribution;
    }
    //Contribution - Special Events RecordType
    if(rtps=='012S0000000D3QKIA0'){
        return Page.znewopptystep_Contribution_SpecialEvents;
    }
        return null;
    }

 Here is my test method:

 

    static testMethod void testSaveone() 
  {  
    ZnewOpportunityController ext = new ZnewOpportunityController();
    
    Account acct = ext.getAccount();
    acct.name='sss';
    acct.Org_Recognition_Name__c='UFC';
    acct.Type='Individual';
    acct.Relationship_Stage__c='Lead';
    acct.BillingState='CT';
    acct.BillingStreet='134 Laurel';
    acct.BillingCity='Mineola';
    acct.BillingPostalCode='11501';
    acct.BillingCountry='USA';
    acct.ShippingState = 'CT';
    acct.ShippingCountry = 'USA';
    acct.ShippingPostalCode = '11501';
    acct.ShippingCity = 'Mineola';
    acct.ShippingStreet = '134 Laurel';
    acct.recordtypeid = '012700000005UJ9AAM';
    
    Contact con = ext.getContact();
    con.AccountId = acct.Id;
    con.firstname='jdhjd';
    con.lastname='hdjdhdh';
    con.email='hello@email.com';
    con.phone='5161231234';
    con.recordtypeid = '012700000005ITPAA2';
    
    
    Opportunity opp = ext.getOpportunity();
    opp.Name = 'lslsls';
    opp.Accountid=acct.id;
    opp.stageName='Lead';
    opp.CloseDate=Date.newinstance(2010,12,31);
    opp.Acknowledge_Type__c = 'City';
    opp.Funding_Source__c = 'Individual';
    opp.Public_Private_Funding__c = 'Public';
    opp.StageName = 'Prospect';
    opp.Reinvestment__c = 'Reinvestment';
    opp.FYs_Applied_To__c = 'FY11'; 
    opp.recordtypeid ='012S0000000D3Q5IAK';  
      
   PageReference testprA = Page.znewopptystep_Contribution;
   Test.setCurrentPage(testprA);
  ext.Step3();
}

 Any advice please

 

 

Hi all:

   I really need help...

in my Apex Controller, I have:

 

    public PageReference addmore2() {
     
    //Payment Detail
    pd.Donation__c = ApexPages.currentPage().getParameters().get('oppid');
 insert pd;
}

 So as you can see I am calling Donation__c which is a required field for Payment DETAIL.

It works but in my unit test class I get:

System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Donation__c]: [Donation__c]

 

 

 

static testMethod void testaddingmore2payments() {
    ZnewOpportunityController ext = new ZnewOpportunityController();

    Account acct2 = ext.getAccount();
    acct2.name='scde';
    acct2.Org_Recognition_Name__c='UFCdd';
    acct2.Type='Individual';
    acct2.Relationship_Stage__c='Lead';
    acct2.BillingState='CT';
    acct2.BillingStreet='134 Laurel';
    acct2.BillingCity='Mineola';
    acct2.BillingPostalCode='11501';
    acct2.BillingCountry='USA';
    acct2.ShippingState = 'CT';
    acct2.ShippingCountry = 'USA';
    acct2.ShippingPostalCode = '11501';
    acct2.ShippingCity = 'Mineola';
    acct2.ShippingStreet = '134 Laurel';
    acct2.recordtypeid = '012700000005UJ9AAM';
    
    Contact con2 = ext.getContact();
    con2.AccountId = acct2.Id;
    con2.firstname='jdhjdss';
    con2.lastname='hdjdhdhzz';
    con2.email='hellozz@email.com';
    con2.phone='5161111111';
    con2.recordtypeid = '012700000005ITPAA2';    
    
    Opportunity opp2 = ext.getOpportunity();
    opp2.Name = 'lslslsdsaaa';
    opp2.Accountid = acct2.id;
    opp2.stageName = 'Lead';
    opp2.CloseDate = Date.newinstance(2010,12,31);
    opp2.Acknowledge_Type__c = 'City';
    opp2.Funding_Source__c = 'Individual';
    opp2.Public_Private_Funding__c = 'Public';
    opp2.StageName = 'Prospect';
    opp2.Reinvestment__c = 'Reinvestment';
    opp2.FYs_Applied_To__c = 'FY11'; 
    opp2.recordtypeid ='012700000000vQxAAI';  
    
    Payment_Detail__c pmt2 = ext.getPaymentDetail();        
    pmt2.Donation__c = opp2.Id;
    pmt2.Applies_To_FY__c = 'FY11';
    pmt2.Date_Due__c = Date.newinstance(2010,12,31);
    pmt2.Amount_Due__c =100;
    pmt2.Date_Received__c = Date.newinstance(2010,12,31);
    pmt2.Amount_Paid__c = 100;
    pmt2.Check_Date__c=Date.newinstance(2010,12,31);
    pmt2.Check_Number__c='112';
    pmt2.Check_Bank__c='hehehe';
    pmt2.recordtypeid = '012700000009PxrAAE';
  
    
    Allocation__c alloc2 = ext.getAllocation ();    
    alloc2.Donation__c = opp2.id;
    alloc2.Payment_Detail__c = pmt2.id;
    alloc2.Amount_allocated__c = 100;
    alloc2.FY_Allocated_To__c = 'FY11';
    alloc2.Program_Location__c = 'Chicago'; 
    
    
    ext.addmore2();
  }

 

Please any any advice would help...

 

 

Hi Everyone:

   I do not understand why is my getCustomers method timing out to too many SOQL Queries?? When I remove the method it works...

Here is the error on my log:

Class.compensationreport.getCustomers: line 148, column 1

Class.compensationreport.query: line 227, column 1

 

Please help....and I keep getting Apex Governor Limit Warning that states Number of SOQL queries: 77 out of 100???

Thanks

Z

 

public class compensationreport{
    public string AAid{get;set;}
    public string AAWid{get;set;}
    public string AATid{get;set;}
    public string AACSid{get;set;}
    public string CompName{get;set;}
    public Integer Gross{get;set;}
    public Integer Withdrawn{get;set;}
    public Integer Transferred{get;set;}
    public Integer Customers{get;set;}
    public String Level { get { return Level ;} set { Level=value ; } } 
    public String Monthrun { get { return Monthrun ;} set { Monthrun=value ; } }    
    
    public List<GrossHolder> queryResults{ get; set; }  
    public class GrossHolder {       
        public String AAName {get; set;}
        public Integer TotalGross {get; set;}
        public String compid{get;set;}    
        public GrossHolder(){}
    }
    
/*******************************************TOTAL Withdrawn******************************************************************************************/

    public List<WithdrawnHolder> queryResultsW{ get; set; }  
    public class WithdrawnHolder {
        public Integer TotalW {get; set;}
        public String AANameW {get; set;}
        public String aax {get;set;}
        public WithdrawnHolder(){}
    }
 
    public String getWithdrawn(String id){
    List<SObject> qrystringW = new List<SObject>();
        if(Monthrun=='THIS_MONTH'){
            qrystringW = [SELECT Ownerid,Count(Id) ce 
                            FROM Opportunity Where 
                            Withdrawn__c = True 
                            AND StageName = 'Closed Won' 
                            AND Withdrawal_Status__c ='Withdrawn' 
                            AND Withdrawn_Date__c = THIS_MONTH
                            AND Ownerid=:id 
                            AND (NOT Name Like '%COMP%')
                            GROUP BY Ownerid]; 
        }
        else {
            qrystringW = [SELECT Ownerid,Count(Id) ce 
                            FROM Opportunity Where 
                            Withdrawn__c = True 
                            AND StageName = 'Closed Won' 
                            AND Withdrawal_Status__c ='Withdrawn' 
                            AND Withdrawn_Date__c = LAST_MONTH
                            AND Ownerid=:id 
                            AND (NOT Name Like '%COMP%')
                            GROUP BY Ownerid]; 
        
        }
                            
    AggregateResult[] groupedResults = qrystringW; 
        
    queryResultsW = new List<WithdrawnHolder>();
    
    for (AggregateResult ar : groupedResults)  {
        WithdrawnHolder myObject = new WithdrawnHolder();
            myObject.aax = String.valueOf(ar.get('Ownerid'));
            AAWid =  myObject.aax;
            myObject.TotalW = (Integer) ar.get('ce');
        Withdrawn = myObject.TotalW ;    
        queryResultsW.add(myObject); 
    }
        return null;    
}  
/*******************************************TOTAL TRANSFERRED******************************************************************************************/
    public List<WithdrawnHolderT> queryResultsWT{ get; set; }  

    public class WithdrawnHolderT {

        public Integer TotalWT {get; set;}
         public String AANameWT {get; set;}
         public String aaxT {get;set;}
    public WithdrawnHolderT(){
    }
    }
 
    public String getWithdrawnT(String id){
    List<SObject> qrystringT = new List<SObject>();
        if(Monthrun=='THIS_MONTH'){
            qrystringT = [SELECT Ownerid,Count(Id) ce 
                            FROM Opportunity Where 
                            Withdrawn__c = True 
                            AND StageName = 'Closed Won' 
                            AND Withdrawal_Status__c = 'Transferred to DL' 
                            AND Withdrawn_Date__c = THIS_MONTH  
                            AND Ownerid=:id 
                            AND (NOT Name Like '%COMP%')
                            GROUP BY Ownerid]; 
         }
         else {
              qrystringT = [SELECT Ownerid,Count(Id) ce 
                            FROM Opportunity Where 
                            Withdrawn__c = True 
                            AND StageName = 'Closed Won' 
                            AND Withdrawal_Status__c = 'Transferred to DL' 
                            AND Withdrawn_Date__c = LAST_MONTH  
                            AND Ownerid=:id 
                            AND (NOT Name Like '%COMP%')
                            GROUP BY Ownerid];        
         }                   
    AggregateResult[] groupedResults = qrystringT; 
        
    queryResultsWT = new List<WithdrawnHolderT>();
    
    for (AggregateResult ar : groupedResults)  {
        WithdrawnHolderT myObject = new WithdrawnHolderT();
        myObject.aaxT = String.valueOf(ar.get('Ownerid'));
        AATid =  myObject.aaxT;
        myObject.TotalWT = (Integer) ar.get('ce');
        Transferred = myObject.TotalWT ;
    
    queryResultsWT.add(myObject); 
      
    }
    return null;    
    }  
/*******************************************TOTAL CUSTOMERS******************************************************************************************/    
    public List<customers> queryResultscs{ get; set; }  
    public class customers {

        public Integer TotalCS {get; set;}
         public String AANameCS {get; set;}
         public String aaxCS {get;set;}
    public customers(){
    }
    }
 
    public String getCustomers(String id){
    List<SObject> qrystringc = new List<SObject>();
        if(Monthrun=='THIS_MONTH'){
            qrystringc = [SELECT Ownerid,Count(Id) ce 
                            FROM Account 
                            Where Owner.Role_Name__c Like '%Advisor%' 
                            AND Ownerid=:id AND CreatedDate = THIS_MONTH
                            GROUP BY Ownerid];
        }
        else{
            qrystringc = [SELECT Ownerid,Count(Id) ce 
                            FROM Account 
                            Where Owner.Role_Name__c Like '%Advisor%' 
                            AND Ownerid=:id AND CreatedDate = LAST_MONTH
                            GROUP BY Ownerid];        
        }
    
    
    AggregateResult[] groupedResults = qrystringc;  
        
    queryResultscs = new List<customers>();
    
    for (AggregateResult ar : groupedResults)  {
        customers myObject = new customers();
        myObject.aaxCS = String.valueOf(ar.get('Ownerid'));
        AACSid =  myObject.aaxCS;
        myObject.TotalCS = (Integer) ar.get('ce');
        Customers = myObject.TotalCS ;
    
    queryResultscs.add(myObject); 
      
    }
    return null;    
    }                               
/*******************************************Actual******************************************************************************************/     
public PageReference query() { 
Date Lastmonthfirst;
Date Lastmonthend;

Date selectedDate =  Date.Today(); //Give your date
Date firstDate = selectedDate.toStartOfMonth();
Date lastDate = firstDate.addDays(date.daysInMonth(selectedDate.year() , selectedDate.month())  - 1);
system.debug(firstDate  + ' **** ' +lastDate );
//******************************************************************************************************
Lastmonthfirst = selectedDate.toStartOfMonth().addMonths(-1);
Lastmonthend = Lastmonthfirst.addDays(date.daysInMonth(Lastmonthfirst.year() , Lastmonthfirst.month())  - 1);
system.debug(Lastmonthfirst  + ' **** ' +Lastmonthend );

     
    List<Compensation__c>  delmarker = new List<Compensation__c>(); 
    If(Monthrun=='THIS_MONTH'){
        delmarker=[select id from Compensation__c where Date_ran__c =THIS_MONTH];
    }
    else{delmarker=[select id from Compensation__c where Date_ran__c =LAST_MONTH];}
    
    for(Compensation__c sm:delmarker){
        delete sm;
    }  
       
    List<SObject> qrystringf =new List<SObject>();
        if(Monthrun=='THIS_MONTH'){
            qrystringf=[SELECT Ownerid, Count(Id) ce
                        FROM Opportunity Where Comp__c=False  
                        AND CloseDate=THIS_MONTH 
                        AND StageName = 'Closed Won'
                        GROUP BY Ownerid];
    }
    else
    {
            qrystringf=[SELECT Ownerid, Count(Id) ce
                        FROM Opportunity Where Comp__c=False  
                    AND CloseDate=LAST_MONTH 
    AND StageName = 'Closed Won'
    GROUP BY Ownerid];           
    }         
  If (Level=='AA'){
       
              AggregateResult[] groupedResults = qrystringf; 

                                      
    queryResults = new List<GrossHolder>();
    for (AggregateResult ar : groupedResults)  {
        GrossHolder myObject = new GrossHolder();
            myObject.TotalGross = (Integer) ar.get('ce');
            myObject.compid = String.valueOf(ar.get('Ownerid'));
            AAid = myObject.compid;
            
            getWithdrawn(AAid);
            getWithdrawnT(AAid);
            getCustomers(AAid);
/*****************************INSERT COMP**********************************************************************/

            Compensation__c cmp = new Compensation__c();
            cmp.Name__c = myobject.compid;
            cmp.Comp_Plan__c ='AA';
            cmp.Total_Gross__c = myObject.TotalGross;
            IF(Monthrun=='THIS_MONTH'){            
                cmp.Date_ran__c = date.TODAY();
            }
            else{
                cmp.Date_ran__c = Lastmonthfirst;
            }
                
               if(AAWid!=AAid){
                    cmp.Total_Withdrawn__c = 0;
                }
                else{
                    cmp.Total_Withdrawn__c = Withdrawn;
                    if(cmp.Total_Withdrawn__c == null){
                        cmp.Total_Withdrawn__c = 0;
                    }                    
                }
                 
                if(AATid!=AAid){
                    cmp.Total_Transfers__c = 0;
                }
                else{
                    cmp.Total_Transfers__c = Transferred;
                    if(cmp.Total_Transfers__c == null){
                        cmp.Total_Transfers__c = 0;
                    }
               } 
               
                if(AACSid!=AAid){
                    cmp.Total_Customers__c = 0;
                }
                else{
                    cmp.Total_Customers__c = Customers;
                    if(cmp.Total_Customers__c == null){
                        cmp.Total_Customers__c = 0;
                    }
               }                                
                insert cmp;
        queryResults.add(myObject); 
        }
        }
        return null;
    } 
}

 

HI:

   I have a table with bonus amounts in it depending on Comp_Plan

If the Level of the Person is 100 let's say and in the CompPlan table a level of 100 is $2000, and another level of a person is 60 and bonus is $1000...

My code is picking up the $1000 instead of $2000 when the level of that person is 120...

trigger bonusAmount on Compensation__c (before insert,before update) {

    List<Compensation__c> pu = new List<Compensation__c>();

    

         
         for(Compensation__c o: Trigger.New){
             List<Comp_Plan__c> accountWithOpptys = [Select id, Comp__c,Goal__c,Category__c,Goal_Amount__c,Level__c from Comp_Plan__c where Team_Goal__c=True AND Comp__c =:o.Comp_plan__c];            
            System.Debug('***'+accountWithOpptys.size() + o.Comp_Plan__c); //This is correct brings up 8 records for Comp_Plan__c=AA and the levels from 30-100 with the Goal_Amount...
 
            if(o.NELevel__c >= 100){ //In the record I am editing the level is 120 which is greater then 100 but the person should get 2500 yet it is getting 1000 which the 1000 is for level 60????
                 o.NEBonus__c = accountWithOpptys[0].Goal_Amount__c;            
            pu.add(o);
            }
        }
}

 Hope this helps please...

thanks

Z

 

Hi:

   Does anyone know what is wrong with my statement:

 

public class Productff {

//Define your variables
public class OppStageHolder {
    public String OPP {get; set;}
    public Integer TTL_Opp {get; set;}
//Empty Array    
public OppStageHolder (){}
}
//Results will be placed within this List
public List queryResults {get;set;}

//Your Page
public PageReference TTL() {

AggregateResult[] groupedResults = [SELECT Product_Name__c, Sum(TotalPrice) ce FROM OpportunityLineItem 
                                    GROUP BY Product_Name__c];  
System.Debug('zzavg ' + groupedResults.size());
//Define your List
queryResults = new List();

for (AggregateResult ard : groupedResults)  {    
    OppStageHolder myObject = new OppStageHolder();    
    myObject.OPP = String.valueOf(ard.get('Product_Name__c'));    
    myObject.TTL_Opp = (Integer) ard.get('ce');         
    queryResults.add(myObject);    
}
return Page.TTL;
}


}

 

 

 

<apex:outputField value="{!a.total.TotalPrice}"/>

 

What is wrong with this?

 

Because I am getting this: Error:Currency fields on entities with effective dated currency are not supported???

Hi:

   What is this error:

System.LimitException: Too
many query rows: 725 stacktrace

What is wrong with my method here... this is where I am getting the error.

 

 

public List<Opportunity> getOpportunities(){
      
        opportunities = [Select o.name, o.CloseDate, 
            (Select x_CC__c From cv__R00N40000001X8re__r) 
        FROM Opportunity o 
        WHERE x_Date__c = NULL 
        AND StageName = 'Received' ORDER BY CloseDate];

      return opportunities;
    }

 

 

Hi:

   Has anyone try to do a web-to-case and within the form give the ability of uploading an attachment to that case???

I can not seem to figure it out?

Any thoughts???

thanks

hi the following is the page reference in my apex controller:

 

public PageReference step3() {
    //Contribution RecordType
    if(rtps=='012S0000000D3Q5IAK'){
        return Page.znewopptystep_Contribution;
    }
    //Contribution - Special Events RecordType
    if(rtps=='012S0000000D3QKIA0'){
        return Page.znewopptystep_Contribution_SpecialEvents;
    }
        return null;
    }

 Here is my test method:

 

    static testMethod void testSaveone() 
  {  
    ZnewOpportunityController ext = new ZnewOpportunityController();
    
    Account acct = ext.getAccount();
    acct.name='sss';
    acct.Org_Recognition_Name__c='UFC';
    acct.Type='Individual';
    acct.Relationship_Stage__c='Lead';
    acct.BillingState='CT';
    acct.BillingStreet='134 Laurel';
    acct.BillingCity='Mineola';
    acct.BillingPostalCode='11501';
    acct.BillingCountry='USA';
    acct.ShippingState = 'CT';
    acct.ShippingCountry = 'USA';
    acct.ShippingPostalCode = '11501';
    acct.ShippingCity = 'Mineola';
    acct.ShippingStreet = '134 Laurel';
    acct.recordtypeid = '012700000005UJ9AAM';
    
    Contact con = ext.getContact();
    con.AccountId = acct.Id;
    con.firstname='jdhjd';
    con.lastname='hdjdhdh';
    con.email='hello@email.com';
    con.phone='5161231234';
    con.recordtypeid = '012700000005ITPAA2';
    
    
    Opportunity opp = ext.getOpportunity();
    opp.Name = 'lslsls';
    opp.Accountid=acct.id;
    opp.stageName='Lead';
    opp.CloseDate=Date.newinstance(2010,12,31);
    opp.Acknowledge_Type__c = 'City';
    opp.Funding_Source__c = 'Individual';
    opp.Public_Private_Funding__c = 'Public';
    opp.StageName = 'Prospect';
    opp.Reinvestment__c = 'Reinvestment';
    opp.FYs_Applied_To__c = 'FY11'; 
    opp.recordtypeid ='012S0000000D3Q5IAK';  
      
   PageReference testprA = Page.znewopptystep_Contribution;
   Test.setCurrentPage(testprA);
  ext.Step3();
}

 Any advice please

 

 

hi all:

   I would apprceiate any help here...

I have this formula that I am doing bacially it is:

If the sum of Exp + Comp >= 10 then it is Tier 1

if it is between 6 and 9 then its 2

if it is between 3-5 its 3

if it is 4 then its sorry not qualified

 

Here is my formula... I started it check syntax and I got a wierd error message:

Error: Compiled formula is too big to execute (7,776 characters). Maximum size is 5,000 characters

 

IF(Exp_No_Selected__c+Comp_Selected__c >= 10,'Tier 1', 
IF((Exp_No_Selected__c+Comp_Selected__c  >= 6) && (Exp_No_Selected__c+Comp_Selected__c  <= 9),'Tier 2', '')
)

 Can anyone dumb it down for me... Cause I am lost...

 

Hi:

   Wondering if I write a trigger and Wanted it to fire off when the user clicks on Convert Lead .... My Trigger is not updating the Custom Object Recruiting Touchpoint and the field within it Contact????

Would I do an After update

 

trigger Z_TierLeadConvert on Lead (after update) {
List<Recruiting_TouchPoint__c> updatedRT = new List<Recruiting_TouchPoint__c>();
  for(Lead lead:System.Trigger.new) {
        if (lead.IsConverted) {
            
            Contact con = [SELECT Id,Tier_Score__c,TouchPoint_Date__c 
                            FROM Contact WHERE Contact.Id = :lead.ConvertedContactId];
                con.Tier_Score__c = lead.Tier_Score__c;
                con.TouchPoint_Date__c = lead.TouchPoint_Date__c;
            update con;
            Recruiting_TouchPoint__c allrt= [Select Contact__c
                                                From Recruiting_TouchPoint__c Where
                                                Lead__c = :lead.ConvertedContactId]; 
            allrt.Contact__c = con.Id;
             updatedRT.add(allrt);
        }
    }
    update updatedRT;
}

 

 

Hi I like to do 2 things with one button on my VF page...

1. Export everything on the page to excel

2. Update a field to today date and time (System.Now());

 

 

I tried this but it is updating first and then exporting blanks...

 

public pageReference init(){
setthedate();
pagereference home = new pagereference('/apex/excel');
home.setRedirect(true);
return home;    
}

 

 

In my excel method I am taking in all Opps with the date/time field blank...

But the excel is coming out blank because it is updating before it is exporting it out...

Any thoughts

Hi anyone have a example of when a webservice fails, I am the only one that gets the Apex Error. But i need to have this Apex Error sent out to a whole group of people with a simple Error Message.

Anyone have an example of it?

Thanks

 

Hi all:

   I am building a wizard on 2 custom object and basically the name in one obect is an autonumber. So i need this autonumber to appear in the second object which links to the first custom object.

for some reason it is not working from my VF page when I hit save

 

   public PageReference saveit() {
  
      System.Debug('rtpspm' + ApexPages.currentPage().getParameters().get('rtpspm'));
      System.debug('oppid' + ApexPages.currentPage().getParameters().get('oppId'));
      //Payment Detail
      pd.Donation__c = ApexPages.currentPage().getParameters().get('oppId');
      pd.recordtypeid = ApexPages.currentPage().getParameters().get('rtpspm');
      insert pd;
  
      List<Payment_Detail__c> pdName = new List<Payment_Detail__c>();
      pdName = [Select Name from Payment_Detail__c where Id=:pd.id Limit 1];
      System.Debug('pd.Name' + pdName[0].Name);
             
      //Allocation
      alloc.Donation__c = ApexPages.currentPage().getParameters().get('oppId');
      alloc.Payment_Detail__c = pdName[0].Name ;
      insert alloc;


       PageReference opptyPage = new PageReference('/' + ApexPages.currentPage().getParameters().get('oppId'));
       return opptyPage.setRedirect(true);
   

   }

 Where am I going wrong????

 

Hi Pros,

 

i have been trying to auto Populate a field from another field value based on Ajax Triggers, but i get error.

here is the scenario:

Under accounts standard Object i have a custom  field called as Control Location.

Under User standard object i have a custom field also called as Control Location.

 Account and Users are connected based on a lookup of sales Representative (renamed Account Owner field).

i would like to auto populate the account's Control Location based on the value of Control Location in the user Object.

 

here is my Query:

 

 trigger populatecontrolLocation on Account(before insert, before update)

{

    // for each account, create a new trigger

    for(Account a : Trigger.new)

    {

        // Create a list of user records from a SOQL query  

        List <User> accusr = [SELECT Control_Location__c FROM User WHERE id = : a.Ownerid]; 


        // for each account user 

        

        a.Control_Location__c = accusr.get(0);

       

       

    }

        

}

 

 

and here is the error i receive:

 error : Illegal assignment from SOBJECT:User to String

 

 

any suggestions would be more than welcome.

 

best regards,

Mojtaba

 

Hi:

   I gave all security permissions to every profile in the apex classes and VF Pages, all objects are in deployment mode... I do not know what else to do but when my user goes to test into a VF Tab they get the following:

 

Insufficient Privileges You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.

 

What should I do????