• Sheena Querido
  • NEWBIE
  • 30 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 5
    Replies
I need to create a test class, but I'm not sure how to since my Apex Class is essentially a query with a sort functionality and not an action to a field (like the examples I've seen on Trailhead). Any help would be much appreciated. 
 
public class ExhibitAController {
    public Customer_Pricing__c cust{set;get;}
    public List<Customers_Product_Code__c> customerproducts{get;set;}
    public Set<Customers_Product_Code__c> customerproducts2{get;set;}
        
    public ExhibitAController(ApexPages.StandardController stdController){
    
        this.cust = (Customer_Pricing__c)stdController.getRecord();
		cust = [select Id, Account_Name_Text__c, Project_Scope__c,Eff_Start_Date__c,Min_Invoice__c,Assessment__c from Customer_Pricing__c where Id =: cust.Id];
		customerproducts = new List<Customers_Product_Code__c>();
		customerproducts2 = new Set<Customers_Product_Code__c>();
        customerproducts  = [SELECT Description_for_Invoice__c,Caveats__c,Category__c,Container_Size__c,UM__c,Price__c
                             FROM Customers_Product_Code__c
                             where Customer_Pricing__c =:cust.Id
                             ORDER BY Category__c, Description_for_Invoice__c, Container_Size__c]; 
        customerproducts2.addAll(customerproducts);
        for(Integer i = 0; i < customerproducts.size(); i++)
            for(Integer j = i; j < customerproducts.size(); j++)
            {
                if(customerproducts[i].Id != customerproducts[j].Id)
                {
                    if(customerproducts[i].Description_for_Invoice__c == customerproducts[j].Description_for_Invoice__c && customerproducts[i].Container_Size__c == customerproducts[j].Container_Size__c && customerproducts[i].Caveats__c == customerproducts[j].Caveats__c)
                    {
                        customerproducts2.remove(customerproducts[j]);
                    }
                }
            }
        customerproducts.clear();
        customerproducts.addAll(customerproducts2);
    }
}

 
I tried creating a GROUP BY clause in my Apex Class, but I'm getting an error message that Line 9 has Illegal Assignment form List to List

Where Line 9 is: 
customerproducts  = [SELECT Description_for_Invoice__c,TSDF_Approval_Number__c,Caveats__c,Category__c,Container_Size__c,UM__c,Price__c

Entire Apex Class is: 
public class ExhibitAController {
    public Customer_Pricing__c cust {get;set;}
    public List<Customers_Product_Code__c> customerproducts {get;set;}
        
    public ExhibitAController(ApexPages.StandardController stdController){
    
        this.cust = (Customer_Pricing__c)stdController.getRecord();

        customerproducts  = [SELECT Description_for_Invoice__c,TSDF_Approval_Number__c,Caveats__c,Category__c,Container_Size__c,UM__c,Price__c
                             FROM Customers_Product_Code__c 
                             where Customer_Pricing__c =:cust.Id
                             GROUP BY Description_for_Invoice__c,TSDF_Approval_Number__c,Caveats__c,Category__c,Container_Size__c,UM__c,Price__c
                             ORDER BY Category__c, Description_for_Invoice__c, Container_Size__c]
            ; }
}

 
I have a controller for my custom object that is currently sorting columns in my table. However, it's sorting on every column. 
public class ExhibitAController {
    public Customer_Pricing__c cust {get;set;}
    public List<Customers_Product_Code__c> customerproducts {get;set;}
        
    public ExhibitAController(ApexPages.StandardController stdController){
    
        this.cust = (Customer_Pricing__c)stdController.getRecord();

        customerproducts  = [select Description_for_Invoice__c,TSDF_Approval_Number__c,Caveats__c,Category__c,Container_Size__c,UM__c,Price__c from Customers_Product_Code__c where Customer_Pricing__c =:cust.Id];
    
            customerproducts.sort();

    }
    

    
}

How do I adjust the code to only sort on columns/fields that I specify? 
Is there a way via Visual Workflow or an Apex trigger to be navigated from the Opportuntiy Page to the Contract Page? 

I know you can create a Contract record in the background for when an Opportuntiy is put in a stage of "Closed Won" using Process Builder, but is there a way to actually be taken to the contract page/screen? 

Any help is appreciated. Thank you in advance.
I tried creating a formula, but I got an error message that said there were too many characters in my formula.  Any ideas on how to shorten the formula is much appreciated!
 
Error: Invalid Data. 
Review all error messages below to correct your data.
Compiled formula is too big to execute (9,526 characters). Maximum size is 5,000 characters (Related field: Formula)

 
IF(ISPICKVAL(Frequency_of_Service__c, "One-time"),
ABS((Cost__c * Probability) / 1),

IF(ISPICKVAL(Frequency_of_Service__c, "Yearly"),
ABS((Cost__c * Probability) / 1),

IF(ISPICKVAL(Frequency_of_Service__c, "Twice Yearly"),
ABS((Cost__c * Probability) / 2),

IF(ISPICKVAL(Frequency_of_Service__c, "Quarterly"),
ABS((Cost__c * Probability) / 4),

IF(ISPICKVAL(Frequency_of_Service__c, "Monthly"),
ABS((Cost__c * Probability) / 12),

IF(ISPICKVAL(Frequency_of_Service__c, "Twice Monthly"),
ABS((Cost__c * Probability) / 12),

IF(ISPICKVAL(Frequency_of_Service__c, "Weekly"),
ABS((Cost__c * Probability) / 12),

IF(ISPICKVAL(Frequency_of_Service__c, "Twice Weekly"),
ABS((Cost__c * Probability) / 12),

IF(ISPICKVAL(Frequency_of_Service__c, "Daily"),
ABS((Cost__c * Probability) / 12),

0
)))))))))

Where the field Cost__c is another formula:
 
IF(ISPICKVAL(Margin__c , "60"), 
ABS((Amount -(0.60 * Amount))), 

IF(ISPICKVAL(Margin__c , "50"), 
ABS((Amount -(0.50 * Amount))), 

IF(ISPICKVAL(Margin__c , "40"), 
ABS(( Amount -(0.40 * Amount))), 

IF(ISPICKVAL(Margin__c , "45"), 
ABS((Amount -(0.45 * Amount))), 

IF(ISPICKVAL(Margin__c , "35"), 
ABS((Amount -(0.35 * Amount))), 

IF(ISPICKVAL(Margin__c , "30"), 
ABS((Amount -(0.30 * Amount))), 

0 
))))))
I tried creating the following formula, but I got an error message that said there were too many characters in my formula. I'm trying to use the CONTAINS function, but I'm losing my formula ... any help is appreciated. 

IF(ISPICKVAL(Service_Type_del__c, "One-time"),
ABS((Cost__c * Probability) / 1),

IF(ISPICKVAL(Service_Type_del__c, "Yearly"),
ABS((Cost__c * Probability) / 1),

IF(ISPICKVAL(Service_Type_del__c, "Twice Yearly"),
ABS((Cost__c * Probability) / 2),

IF(ISPICKVAL(Service_Type_del__c, "Quarterly"),
ABS((Cost__c * Probability) / 4),

IF(ISPICKVAL(Service_Type_del__c, "Monthly"),
ABS((Cost__c * Probability) / 12),

IF(ISPICKVAL(Service_Type_del__c, "Twice Monthly"),
ABS((Cost__c * Probability) / 12),

IF(ISPICKVAL(Service_Type_del__c, "Weekly"),
ABS((Cost__c * Probability) / 12),

IF(ISPICKVAL(Service_Type_del__c, "Twice Weekly"),
ABS((Cost__c * Probability) / 12),

IF(ISPICKVAL(Service_Type_del__c, "Daily"),
ABS((Cost__c * Probability) / 12),

0
)))))))))
I have a controller for my custom object that is currently sorting columns in my table. However, it's sorting on every column. 
public class ExhibitAController {
    public Customer_Pricing__c cust {get;set;}
    public List<Customers_Product_Code__c> customerproducts {get;set;}
        
    public ExhibitAController(ApexPages.StandardController stdController){
    
        this.cust = (Customer_Pricing__c)stdController.getRecord();

        customerproducts  = [select Description_for_Invoice__c,TSDF_Approval_Number__c,Caveats__c,Category__c,Container_Size__c,UM__c,Price__c from Customers_Product_Code__c where Customer_Pricing__c =:cust.Id];
    
            customerproducts.sort();

    }
    

    
}

How do I adjust the code to only sort on columns/fields that I specify? 
I tried creating a formula, but I got an error message that said there were too many characters in my formula.  Any ideas on how to shorten the formula is much appreciated!
 
Error: Invalid Data. 
Review all error messages below to correct your data.
Compiled formula is too big to execute (9,526 characters). Maximum size is 5,000 characters (Related field: Formula)

 
IF(ISPICKVAL(Frequency_of_Service__c, "One-time"),
ABS((Cost__c * Probability) / 1),

IF(ISPICKVAL(Frequency_of_Service__c, "Yearly"),
ABS((Cost__c * Probability) / 1),

IF(ISPICKVAL(Frequency_of_Service__c, "Twice Yearly"),
ABS((Cost__c * Probability) / 2),

IF(ISPICKVAL(Frequency_of_Service__c, "Quarterly"),
ABS((Cost__c * Probability) / 4),

IF(ISPICKVAL(Frequency_of_Service__c, "Monthly"),
ABS((Cost__c * Probability) / 12),

IF(ISPICKVAL(Frequency_of_Service__c, "Twice Monthly"),
ABS((Cost__c * Probability) / 12),

IF(ISPICKVAL(Frequency_of_Service__c, "Weekly"),
ABS((Cost__c * Probability) / 12),

IF(ISPICKVAL(Frequency_of_Service__c, "Twice Weekly"),
ABS((Cost__c * Probability) / 12),

IF(ISPICKVAL(Frequency_of_Service__c, "Daily"),
ABS((Cost__c * Probability) / 12),

0
)))))))))

Where the field Cost__c is another formula:
 
IF(ISPICKVAL(Margin__c , "60"), 
ABS((Amount -(0.60 * Amount))), 

IF(ISPICKVAL(Margin__c , "50"), 
ABS((Amount -(0.50 * Amount))), 

IF(ISPICKVAL(Margin__c , "40"), 
ABS(( Amount -(0.40 * Amount))), 

IF(ISPICKVAL(Margin__c , "45"), 
ABS((Amount -(0.45 * Amount))), 

IF(ISPICKVAL(Margin__c , "35"), 
ABS((Amount -(0.35 * Amount))), 

IF(ISPICKVAL(Margin__c , "30"), 
ABS((Amount -(0.30 * Amount))), 

0 
))))))
I tried creating the following formula, but I got an error message that said there were too many characters in my formula. I'm trying to use the CONTAINS function, but I'm losing my formula ... any help is appreciated. 

IF(ISPICKVAL(Service_Type_del__c, "One-time"),
ABS((Cost__c * Probability) / 1),

IF(ISPICKVAL(Service_Type_del__c, "Yearly"),
ABS((Cost__c * Probability) / 1),

IF(ISPICKVAL(Service_Type_del__c, "Twice Yearly"),
ABS((Cost__c * Probability) / 2),

IF(ISPICKVAL(Service_Type_del__c, "Quarterly"),
ABS((Cost__c * Probability) / 4),

IF(ISPICKVAL(Service_Type_del__c, "Monthly"),
ABS((Cost__c * Probability) / 12),

IF(ISPICKVAL(Service_Type_del__c, "Twice Monthly"),
ABS((Cost__c * Probability) / 12),

IF(ISPICKVAL(Service_Type_del__c, "Weekly"),
ABS((Cost__c * Probability) / 12),

IF(ISPICKVAL(Service_Type_del__c, "Twice Weekly"),
ABS((Cost__c * Probability) / 12),

IF(ISPICKVAL(Service_Type_del__c, "Daily"),
ABS((Cost__c * Probability) / 12),

0
)))))))))