• Mr.Brooks
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 16
    Replies
I am trying to see why this error is occuring for my query. Help would be greatly appreciated.

 List<ContentVersion> cv = [Select Title, portal_effective_date__c, Portal_Effective_Until_Date__c,description, filetype, createddate, isLatest, id, brand__c, state__c, region__c, 
                                           dealer__c from contentversion where ContentDocumentId in (SELECT ContentDocumentId FROM ContentWorkspaceDoc WHERE ContentWorkspaceId = :workspaceId) 
                                           and (Brand__C ='' and region__C = '' and state__c ='') OR region__C = :selRegion OR state__c = :acc.Physical_State__c OR 
                                           (region__C = :selRegion and state__c = :acc.Physical_State__c) and isLatest = true order by Title ASC];
I created a VF page to mock the notes and attachments related list. Now i have it to where the attachments are inserted on top of the notes. How can I get them  sorted by created date to make them mix in with each other instead of attachments being on top and notes being underneath. Any help is appreciated. Thanks.

global class NotesAttachment{
   
    public List<Note> n1 {get;set;}
    public List<Tuple> combinations{get;set;}
    public string ecid{get;set;}
    public string dcid{get;set;}
    public Datetime CreatedDate;
    String strid = System.currentPagereference().getParameters().get('id');
    public sObject Tuppy;   
    public List<Tuple> pageCombinations {get;set;}
    private Integer pageNumber;
    private Integer PageSize;
    private Integer totalPageNumber;
   
   
   
    public Integer getPageNumber(){
       return pageNumber;
    }
    public Integer getPageSize(){
       return pageSize;
    }
    public Boolean getPreviousButtonEnabled(){
           return !(pageNumber> 1);
   
    }
   
    public Integer getTotalPageNumber(){
       if(totalPageNumber == 0 && combinations != null){

        totalPageNumber = combinations.size() / pageSize;
        Integer mod = combinations.size() - (totalPageNumber * pageSize);
        if(mod > 0)
        totalPageNumber++;
        }
    return totalPageNumber;
    }
   
  
   
    public NotesAttachment(ApexPages.StandardController stdController)
     {
        
       //rlucas Paging
       pageNumber = 0;
       totalPageNumber = 0;
       pageSize = 7;
       ViewData();  

    }
   
    //rlucas view note/attachment
    public PageReference ViewData()
    {
        combinations = null;
        totalPageNumber = 0;
        BindData(1);
        return null;
    }
    private void BindData(Integer newPageIndex){
    try{
        //if(combinations == null)
        combinations = new List<Tuple>();
  
        Tuple tr;
        List<Attachment> atts =[SELECT Id, Name, createdbyid, createdDate, lastmodifieddate, ContentType, BodyLength, parentID FROM Attachment where parentid=:ApexPages.currentPage().getParameters().get('Id') order by createddate desc];
        List<Note> nt = [select Body, CreatedById, createdDate,Id, Title, parentID, LastModifieddate from Note where parentid=:ApexPages.currentPage().getParameters().get('Id') order by createdDate desc];
        for(Attachment att : atts){
                //Instantiating the wrapper sObject
                tr = new Tuple();
               
                //Assigning the wrapper variables
                tr.title = att.Name;
                tr.parentID = att.parentID;
                tr.CreatedById = att.CreatedById;
                tr.body = att.ContentType;
                tr.id = att.id;
                tr.LastModifieddate = att.LastModifieddate;
           
                //*Add everything to the List then and there*/
                combinations.add(tr);
            
        } 
         
      
        for(Note con : nt){
            tr = new Tuple();
            tr.title = con.title;
            tr.parentID = con.parentID;
            tr.CreatedById = con.CreatedById;
            tr.body = con.Body;
            tr.id = con.id;
            tr.LastModifieddate = con.LastModifieddate;
           
            /*Add the TableRow to the List then and there*/
            combinations.add(tr);
       }
  
       pageCombinations = new List<Tuple>();
       Transient Integer counter = 0;
       Transient Integer min = 0;
       Transient Integer max = 0;
       if(newPageIndex > pageNumber){
            min = pageNumber * pageSize;
            max = newPageIndex * pageSize;
        } else {
           max = newPageIndex * pageSize;
           min = max - pageSize;
        }
        for(Tuple t : combinations){
           counter ++;
           if(counter > min && counter <=max)
           pageCombinations.add(t);
        }
        pageNumber = newPageIndex;
        if(pageCombinations == null || pageCombinations.size() <= 0)
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'Data not available for this view.'));
    }
    catch(Exception ex)
    {
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,ex.getMessage()));
    }
    }
   
    public Boolean getNextButtonDisabled(){
       if(combinations == null) return true;
       else
       return((pageNumber * pageSize) >= combinations.size());

    }
    public PageReference nextBtnClick(){
        BindData(pageNumber + 1);
    return null;
    }
    public PageReference previousBtnClick(){
        BindData(pageNumber - 1);
    return null;

    }
   
   
   
    //wrapper class
    global class Tuple
   {
     
      public String id {get; set;}
      public String body  {get; set;}
      public String Title {get; set;}
      public String parentID {get; set;}
      public DateTime LastModifieddate{get; set;}
      public String createdbyid  {get; set;}
      public DateTime CreatedDate {get; set;}
      public String Name {get; set;}
      public String ContentType {get; set;}

    }
   
    public NotesAttachment(){
        combinations = new List<Tuple>();
      
       
    }
I have created a queue that holds data in an object in Salesforce. I have researched others who have had some similar issues but nothing is helping so far. Here is the code for it. I am just not sure how to test it, I have have the code that i tried to test it below as well. Can anyone please help me out and not just send me to a link?

Controller:
public class CreateNewExceptionFromCures{
   
    public String ActRecTypeID = [SELECT Name, Id, DeveloperName, SobjectType FROM RecordType where SobjectType = 'Deal_Exceptions__c' and developerName = 'retail'].Id;
     
       
    //Create method for button to pass thru
    public CreateNewExceptionFromCures(ApexPages.StandardController stdController){
       
        //List deal = Query id, appNum from Cure where id = id of cure page
       
    }  

    //Create blank method{}
    public CreateNewExceptionFromCures(){}

   
   
  
    //create void method to populate field
    public PageReference hello1(){
       
        List<Cure__c> deal = [SELECT Id, Application_Number__c, Applicant_Name__c FROM CURE__c WHERE id = :ApexPages.currentPage().getParameters().get('Id')];
     List<Opportunity> opp = [Select ID, Application_number__c From Opportunity where Application_number__c = :deal[0].Application_number__c];
        
     //exCat = Query for category from Exception Category with description other
     List<Exception_Category__c> exCat = [SELECT Exception_Category_Description__c, Id, Exception_Category_Code__c, Name FROM Exception_Category__c where Exception_Category_Code__c = '99'];
       
     //create new exception record and populate the source field = cure
     Deal_Exceptions__c d = new Deal_Exceptions__c(Opportunity__c = opp[0].ID, Source__c = 'Cure', Category__c = exCat[0].id); //opp, category and recordype is required
           
        System.debug('CATEGORY IS*******: '+ d.category__c);       
        insert d;         
                                 
  PageReference reference=new PageReference('https://cs20.salesforce.com/'+ d.id);
        //PageReference reference = new ApexPages.StandardController(d).view();
       
  reference.setRedirect(true);
        return reference;
    }
}

--------------------------------------------------------------------TEST CLASS----------------------------------------------

@isTest
public class CreateNewExceptionFromCuresTest{
    public CreateNewExceptionFromCuresTest(){
      
        CreateNewExceptionFromCures ne = new CreateNewExceptionFromCures();
       system.assertEquals(page.success, ne.hello1());
      
        Cure__c cur = new Cure__c();
      
        Deal_Exceptions__c d = new Deal_Exceptions__c();
        ApexPages.StandardController std = new ApexPages.StandardController(d);
        CreateNewExceptionFromCures thecontroller1 = new CreateNewExceptionFromCures(std);
        thecontroller1.hello1();
       
    }
   
}
I have created a queue that holds data in an object in Salesforce. I have researched others who have had some similar issues but nothing is helping so far. Here is the code for it. I am just not sure how to test it, I have have the code that i tried to test it below as well. Can anyone please help me out.

public class ExceptionsThunderheadUtil { //create apex class ExceptionsEmailtoThunderhead
    List<User> usr = [SELECT id, alias, phone, name,email FROM User WHERE id = :UserInfo.getUserId()];
    public string emRecip;
    public string emSend;
    public string emSub; //email subject
    public string usrNam; //name of user
    public string usrPh; //users phone number
    public string usrEm; // user email address
    public string dlrNam; //dealer name
    public String dlrFax; //dealer fax number
    public String dlrEm; //dealer email
    public String dlrNum;
    public String subj;
    public String remrk1;
    public String remrk2;
    public String remrk3;
    public String remrk4;
    public String remrk5;
    public String remrk6;
    public String remrk7;
    public String remrk8;
    public String remrk9;
    public String remrk10;
  
  
    /*Not Sure if remarks are being prepopulated
    public decimal AcqFee;
    public decimal FincAmt;
    public decimal FlatFee;
    public decimal PartPct;
    public decimal PartAmt;
    public string reqProg;
    public string fieldLabel;*/
  
  
  
  
    //TESTING FROM A BUTTON
    public ExceptionsThunderheadUtil(ApexPages.StandardController stdController)
    {     
            //Select user info
            List<User> usr = [SELECT id, alias, phone, name,email FROM User WHERE id = :UserInfo.getUserId()];
          
            usrNam = usr[0].name;
          
            usrPh = usr[0].phone;
          
            usrEm =  usr[0].email;
          
            //select dealer fields
            List<Deal_Exceptions__c> ex = [SELECT Id, Application_Number__c, Dealer_Name__c FROM Deal_Exceptions__c WHERE id = :ApexPages.currentPage().getParameters().get('Id')];
            List<Account> acc = [Select ID, name, Inbound_Fax__c, Email_Address__c,Dealer_Number__c From Account where name = :ex[0].Dealer_Name__c];
          
            dlrNam = acc[0].name;
            //dlrFax = acc[0].Inbound_Fax__c;
            dlrFax = '877-567-2831';
            //dlrEm = acc[0].Email_Address__c;
            dlrEm = 'jamie.swingle@gmfinancial.com';
            dlrNum = acc[0].dealer_number__c;
          
          
            Thunderhead_Queue_Outbound__c rec = new Thunderhead_Queue_Outbound__c();

    }
  
    public ExceptionsThunderheadUtil()
    {       


    }
  
    public String getDlrNum(){
  
        return dlrNum;
    }
  
    public void setDlrNum(String s) {
        dlrNum = s;
    }
  
    public String getUsrNam(){
  
        return usrNam;
    }
  
    public void setUsrNam(String s) {
        usrNam = s;
    }
  
    public String getUsrPh(){
  
        return usrPh;
    }
  
     public void setUsrPh(String s) {
        UsrPh = s;
    }
  
    public String getUsrEm(){
  
        return usrEm;
    }
  
    public void setUsrEm(String s) {
        UsrEm= s;
    }
  
    public String getdlrNam(){
  
        return dlrNam;
    }
  
  
    public String getdlrFax(){
  
        return dlrFax;
    }
  
    public String getDlrEm(){
  
        return dlrEm;
    
    }
  
    public void setDlrEm(String s){
  
        dlrEm = s;
      
    }
  
    public void setdlrNam(String s) {
        dlrNam= s;
    }
  
      public void setdlrFax(String s) {
        dlrFax = s;
    }
  
    public String getSubj(){
  
        return subj;
      
    }
  
    public void setSubj(String s){
  
        subj = s;
      
    }
  
    public String getRemrk1(){
  
        return remrk1;
      
    }
    public void setRemrk1(string a){
  
        remrk1 =a;
      
    }
  
    public String getRemrk2(){
  
        return remrk2;
      
    }
    public void setRemrk2(string b){remrk2 =b;}
  
    public String getRemrk3(){
  
        return remrk3;
      
    }
    public void setRemrk3(string s){remrk3 =s;}
  
    public String getRemrk4(){return remrk4;}
    public void setRemrk4(string s){remrk4 =s;}
  
    public String getRemrk5(){return remrk5;}
    public void setRemrk5(string s){remrk5 =s;}
  
    public String getRemrk6(){return remrk6;}
    public void setRemrk6(string s){remrk6 =s;}
  
    public String getRemrk7(){return remrk7;}
    public void setRemrk7(string s){remrk7 =s;}
  
    public String getRemrk8(){return remrk8;}
    public void setRemrk8(string s){remrk8 =s;}
  
    public String getRemrk9(){return remrk9;}
    public void setRemrk9(string s){remrk9 =s;}
  
    public String getRemrk10(){return remrk10;}
    public void setRemrk10(string s){remrk10 =s;}
  
    public PageReference createEmail(){
        //List<Deal_Exceptions__c> ex = [SELECT id, Application_Number__c, Dealer_Name__c FROM Deal_Exceptions__c where id = :exp[0].id];
        //List<Account> acc = [Select ID, name From Account where name = :ex[0].Dealer_Name__c];
        List<Deal_Exceptions__c> ex = [SELECT Id, Application_Number__c, Dealer_Name__c FROM Deal_Exceptions__c WHERE id = :ApexPages.currentPage().getParameters().get('Id')];
        List<Account> acc = [Select ID, name, Inbound_Fax__c, email_address__c, GMF_ACF__c, dealer_number__c  From Account where name = :ex[0].Dealer_Name__c];
        Thunderhead_Queue_Outbound__c em = new Thunderhead_Queue_Outbound__c();// create record in Thunderhead_Queue_Outbound__c
        em.Application_Number__c = ex[0].Application_Number__c;
        em.Dealer_Name__c = ex[0].Dealer_Name__c;
        em.Email_from__c = usr[0].email;
        //em.Email_to__c = acc[0].email_address__c;
        em.Email_to__c = 'jamie.swingle@gmfinancial.com';
        em.dealer_number__c = acc[0].dealer_number__c;
        em.subject__c = subj;
        em.remarks_1__c = remrk1;
        em.remarks_2__c = remrk2;
        em.remarks_3__c = remrk3;
        em.remarks_4__c = remrk4;
        em.remarks_5__c = remrk5;
        em.remarks_6__c = remrk6;
        em.remarks_7__c = remrk7;
        em.remarks_8__c = remrk8;
        em.remarks_9__c = remrk9;
        em.remarks_10__c = remrk10;
        em.Brand_Code__c = acc[0].GMF_ACF__c;
        em.Channel_Indicator__c = 'E';
        em.Letter_Type_Code__c = 'POSTFUND';
        em.Need_To_Send__c = true;
      
        insert em;
      
        PageReference reference=new PageReference('https://cs20.salesforce.com/'+ em.id);
        reference.setRedirect(true);

        return reference;
    }
  
  
    public PageReference createFax(){
          
        List<Deal_Exceptions__c> ex = [SELECT id, Application_Number__c, Dealer_Name__c FROM Deal_Exceptions__c WHERE id =:ApexPages.currentPage().getParameters().get('Id')];
        List<Account> acc = [Select ID, name, Inbound_Fax__c, email_address__c, GMF_ACF__c, Dealer_Number__c  From Account where name = :ex[0].Dealer_Name__c];
        ThunderHead_Queue_Outbound__c fx = new ThunderHead_Queue_Outbound__c();
        fx.Application_Number__c = ex[0].Application_Number__c;
        fx.Dealer_Name__c = ex[0].Dealer_Name__c;
        fx.dealer_number__c = acc[0].dealer_number__c;
      
        //Check Deal and Dealer record to grab this info.
      
        fx.Brand_Code__c = acc[0].GMF_ACF__c;
        fx.Channel_Indicator__c = 'F';
        fx.Fax_From__c = usr[0].name;
        //fx.Fax_Number__c = acc[0].Inbound_Fax__c;
        fx.Fax_To__c = ex[0].Dealer_Name__c;
        fx.Fax_Number__c = '877-567-2831';
        fx.Letter_Type_Code__c = 'POSTFUND';
        fx.Need_To_Send__c = true;
        fx.remarks_1__c = remrk1;
        fx.remarks_2__c = remrk2;
        fx.remarks_3__c = remrk3;
        fx.remarks_4__c = remrk4;
        fx.remarks_5__c = remrk5;
        fx.remarks_6__c = remrk6;
        fx.remarks_7__c = remrk7;
        fx.remarks_8__c = remrk8;
        fx.remarks_9__c = remrk9;
        fx.remarks_10__c = remrk10;
  
        insert fx;
      
        PageReference reference=new PageReference('https://cs20.salesforce.com/'+ fx.id);
        reference.setRedirect(true);

        return reference;
      
    }
  
    //for visualforce page remark counter
    Integer count = 1;
                      
    public PageReference incrementCounter() {
            if(count <10){
            count++;}
            return null;
    }
                  
    public Integer getCount() {
        return count;
    }
}

-----------------------------------------------------------TEST CLASS BELOW------------------------------------------------------------
public class ExceptionsThunderheadUtilTest{
  public string usrNam {get; set;} //name of user
     public string usrPh {get; set;} //users phone number
     public string usrEm {get; set;} // user email address
     public string dlrNam {get; set;} //dealer name
     public String dlrFax {get; set;} //dealer fax number
     public String dlrEm {get; set;} //dealer email
     public String dlrNum {get; set;}
     public String subj{get; set;}
     public String remrk1{get; set;}
     public String remrk2{get; set;}
     public String remrk3{get; set;}
     public String remrk4{get; set;}
     public String remrk5{get; set;}
     public String remrk6{get; set;}
     public String remrk7{get; set;}
        public String remrk8{get; set;}
     public String remrk9{get; set;}
     public String remrk10{get; set;}
   
   
    public ExceptionsThunderheadUtilTest(){
    
       
        ExceptionsThunderheadUtil controller = new ExceptionsThunderheadUtil();
        String nextPage = controller.createEmail().getUrl();
       
        // Verify that page fails without parameters
        System.assertEquals('/apex/failure?error=noParam', nextPage);
       
        Account acc = new Account(name = 'Test Dealer', Inbound_Fax__c='555-555-5255', email_address__c='testdealer@dealer.com', GMF_ACF__c = 'GMF', dealer_number__c='00000');
        insert acc;
        List<Account> accList = [Select ID From Account Limit 1];
       
        User usr = new User(phone = '555-555-5555', firstname ='Test',lastname='One',email = 'test@gmf.com');   
     insert usr;
        List<User> usrList = [Select ID From User Limit 1];
               
        Deal_Exceptions__c ex = new Deal_Exceptions__c();
     insert ex;
        List<Deal_Exceptions__c> exList = [Select ID From Deal_Exceptions__c Limit 1];
       
        ApexPages.StandardController stc = new ApexPages.StandardController(ex);
        ExceptionsThunderheadUtil eth = new ExceptionsThunderheadUtil(stc);
       
        controller = new ExceptionsThunderheadUtil();
       
        controller.UsrNam = 'test';
        System.assertEquals(usrNam, 'test');
       
  controller.usrEm = 'test2';
        System.assertEquals(usrEm, 'test2');

  controller.dlrNam = 'test3';
        System.assertEquals(dlrNam, 'test3');

  controller.dlrFax = 'test4';
        System.assertEquals(dlrFax, 'test4');

  controller.dlrEm = 'test5';
        System.assertEquals(dlrEm, 'test5'); 
       
        controller.dlrNum = 'test6';
        System.assertEquals(dlrNum, 'test6');
       
        controller.usrPh = 'test7';
        System.assertEquals(usrPh, 'test7');
       
        controller.subj = 'test8';
        System.assertEquals(subj, 'test8');
       
        controller.remrk1 = 'test9';
        System.assertEquals(remrk1, 'test9');
       
        controller.remrk2 = 'test10';
        System.assertEquals(remrk2, 'test10');
       
        controller.remrk3 = 'test11';
        System.assertEquals(remrk3, 'test11');
       
        controller.remrk4 = 'test12';
        System.assertEquals(remrk4, 'test12');
       
        controller.remrk5 = 'test13';
        System.assertEquals(remrk5, 'test13');
       
        controller.remrk6 = 'test14';
        System.assertEquals(remrk6, 'test14');
       
        controller.remrk7 = 'test15';
        System.assertEquals(remrk7, 'test15');
       
        controller.remrk8 = 'test16';
        System.assertEquals(remrk8, 'test16');
       
        controller.remrk9 = 'test17';
        System.assertEquals(remrk9, 'test17');
       
        controller.remrk10 = 'test18';
        System.assertEquals(remrk10, 'test18');
       
        nextPage = controller.createEmail().getUrl();
       
        // Verify that the success page displays
        System.assertEquals('/apex/success', nextPage);
        
       
        eth.createEmail();
        eth.createFax();
       
       
    }
}
I have created a queue that holds data in an object in Salesforce. Here is the code for it. I am just not sure how to test it, I have have the code that i tried to test it below as well. Can anyone please help me out.

public class ExceptionsThunderheadUtil { //create apex class ExceptionsEmailtoThunderhead
    List<User> usr = [SELECT id, alias, phone, name,email FROM User WHERE id = :UserInfo.getUserId()];
    public string emRecip;
    public string emSend;
    public string emSub; //email subject
    public string usrNam; //name of user
    public string usrPh; //users phone number
    public string usrEm; // user email address
    public string dlrNam; //dealer name
    public String dlrFax; //dealer fax number
    public String dlrEm; //dealer email
    public String dlrNum;
    public String subj;
    public String remrk1;
    public String remrk2;
    public String remrk3;
    public String remrk4;
    public String remrk5;
    public String remrk6;
    public String remrk7;
    public String remrk8;
    public String remrk9;
    public String remrk10;
   
   
    /*Not Sure if remarks are being prepopulated
    public decimal AcqFee;
    public decimal FincAmt;
    public decimal FlatFee;
    public decimal PartPct;
    public decimal PartAmt;
    public string reqProg;
    public string fieldLabel;*/
   
   
   
   
    //TESTING FROM A BUTTON
    public ExceptionsThunderheadUtil(ApexPages.StandardController stdController)
    {      
            //Select user info
            List<User> usr = [SELECT id, alias, phone, name,email FROM User WHERE id = :UserInfo.getUserId()];
           
            usrNam = usr[0].name;
           
            usrPh = usr[0].phone;
           
            usrEm =  usr[0].email;
           
            //select dealer fields
            List<Deal_Exceptions__c> ex = [SELECT Id, Application_Number__c, Dealer_Name__c FROM Deal_Exceptions__c WHERE id = :ApexPages.currentPage().getParameters().get('Id')];
            List<Account> acc = [Select ID, name, Inbound_Fax__c, Email_Address__c,Dealer_Number__c From Account where name = :ex[0].Dealer_Name__c];
           
            dlrNam = acc[0].name;
            //dlrFax = acc[0].Inbound_Fax__c;
            dlrFax = '877-567-2831';
            //dlrEm = acc[0].Email_Address__c;
            dlrEm = 'jamie.swingle@gmfinancial.com';
            dlrNum = acc[0].dealer_number__c;
           
           
            Thunderhead_Queue_Outbound__c rec = new Thunderhead_Queue_Outbound__c();

    }
   
    public ExceptionsThunderheadUtil()
    {        

 
    }
   
    public String getDlrNum(){
   
        return dlrNum;
    }
   
    public void setDlrNum(String s) {
        dlrNum = s;
    }
   
    public String getUsrNam(){
   
        return usrNam;
    }
   
    public void setUsrNam(String s) {
        usrNam = s;
    }
   
    public String getUsrPh(){
   
        return usrPh;
    }
   
     public void setUsrPh(String s) {
        UsrPh = s;
    }
   
    public String getUsrEm(){
   
        return usrEm;
    }
   
    public void setUsrEm(String s) {
        UsrEm= s;
    }
   
    public String getdlrNam(){
   
        return dlrNam;
    }
   
   
    public String getdlrFax(){
   
        return dlrFax;
    }
   
    public String getDlrEm(){
   
        return dlrEm;
     
    }
   
    public void setDlrEm(String s){
   
        dlrEm = s;
       
    }
   
    public void setdlrNam(String s) {
        dlrNam= s;
    }
   
      public void setdlrFax(String s) {
        dlrFax = s;
    }
   
    public String getSubj(){
   
        return subj;
       
    }
   
    public void setSubj(String s){
   
        subj = s;
       
    }
   
    public String getRemrk1(){
   
        return remrk1;
       
    }
    public void setRemrk1(string a){
   
        remrk1 =a;
       
    }
   
    public String getRemrk2(){
   
        return remrk2;
       
    }
    public void setRemrk2(string b){remrk2 =b;}
   
    public String getRemrk3(){
   
        return remrk3;
       
    }
    public void setRemrk3(string s){remrk3 =s;}
   
    public String getRemrk4(){return remrk4;}
    public void setRemrk4(string s){remrk4 =s;}
   
    public String getRemrk5(){return remrk5;}
    public void setRemrk5(string s){remrk5 =s;}
   
    public String getRemrk6(){return remrk6;}
    public void setRemrk6(string s){remrk6 =s;}
   
    public String getRemrk7(){return remrk7;}
    public void setRemrk7(string s){remrk7 =s;}
   
    public String getRemrk8(){return remrk8;}
    public void setRemrk8(string s){remrk8 =s;}
   
    public String getRemrk9(){return remrk9;}
    public void setRemrk9(string s){remrk9 =s;}
   
    public String getRemrk10(){return remrk10;}
    public void setRemrk10(string s){remrk10 =s;}
   
    public PageReference createEmail(){
        //List<Deal_Exceptions__c> ex = [SELECT id, Application_Number__c, Dealer_Name__c FROM Deal_Exceptions__c where id = :exp[0].id];
        //List<Account> acc = [Select ID, name From Account where name = :ex[0].Dealer_Name__c];
        List<Deal_Exceptions__c> ex = [SELECT Id, Application_Number__c, Dealer_Name__c FROM Deal_Exceptions__c WHERE id = :ApexPages.currentPage().getParameters().get('Id')];
        List<Account> acc = [Select ID, name, Inbound_Fax__c, email_address__c, GMF_ACF__c, dealer_number__c  From Account where name = :ex[0].Dealer_Name__c];
        Thunderhead_Queue_Outbound__c em = new Thunderhead_Queue_Outbound__c();// create record in Thunderhead_Queue_Outbound__c
        em.Application_Number__c = ex[0].Application_Number__c;
        em.Dealer_Name__c = ex[0].Dealer_Name__c;
        em.Email_from__c = usr[0].email;
        //em.Email_to__c = acc[0].email_address__c;
        em.Email_to__c = 'jamie.swingle@gmfinancial.com';
        em.dealer_number__c = acc[0].dealer_number__c;
        em.subject__c = subj;
        em.remarks_1__c = remrk1;
        em.remarks_2__c = remrk2;
        em.remarks_3__c = remrk3;
        em.remarks_4__c = remrk4;
        em.remarks_5__c = remrk5;
        em.remarks_6__c = remrk6;
        em.remarks_7__c = remrk7;
        em.remarks_8__c = remrk8;
        em.remarks_9__c = remrk9;
        em.remarks_10__c = remrk10;
        em.Brand_Code__c = acc[0].GMF_ACF__c;
        em.Channel_Indicator__c = 'E';
        em.Letter_Type_Code__c = 'POSTFUND';
        em.Need_To_Send__c = true;
       
        insert em;
       
        PageReference reference=new PageReference('https://cs20.salesforce.com/'+ em.id);
        reference.setRedirect(true);

        return reference;
    }
   
   
    public PageReference createFax(){
           
        List<Deal_Exceptions__c> ex = [SELECT id, Application_Number__c, Dealer_Name__c FROM Deal_Exceptions__c WHERE id =:ApexPages.currentPage().getParameters().get('Id')];
        List<Account> acc = [Select ID, name, Inbound_Fax__c, email_address__c, GMF_ACF__c, Dealer_Number__c  From Account where name = :ex[0].Dealer_Name__c];
        ThunderHead_Queue_Outbound__c fx = new ThunderHead_Queue_Outbound__c();
        fx.Application_Number__c = ex[0].Application_Number__c;
        fx.Dealer_Name__c = ex[0].Dealer_Name__c;
        fx.dealer_number__c = acc[0].dealer_number__c;
       
        //Check Deal and Dealer record to grab this info.
       
        fx.Brand_Code__c = acc[0].GMF_ACF__c;
        fx.Channel_Indicator__c = 'F';
        fx.Fax_From__c = usr[0].name;
        //fx.Fax_Number__c = acc[0].Inbound_Fax__c;
        fx.Fax_To__c = ex[0].Dealer_Name__c;
        fx.Fax_Number__c = '877-567-2831';
        fx.Letter_Type_Code__c = 'POSTFUND';
        fx.Need_To_Send__c = true;
        fx.remarks_1__c = remrk1;
        fx.remarks_2__c = remrk2;
        fx.remarks_3__c = remrk3;
        fx.remarks_4__c = remrk4;
        fx.remarks_5__c = remrk5;
        fx.remarks_6__c = remrk6;
        fx.remarks_7__c = remrk7;
        fx.remarks_8__c = remrk8;
        fx.remarks_9__c = remrk9;
        fx.remarks_10__c = remrk10;
   
        insert fx;
       
        PageReference reference=new PageReference('https://cs20.salesforce.com/'+ fx.id);
        reference.setRedirect(true);

        return reference;
       
    }
   
    //for visualforce page remark counter
    Integer count = 1;
                       
    public PageReference incrementCounter() {
            if(count <10){
            count++;}
            return null;
    }
                   
    public Integer getCount() {
        return count;
    }
}

-----------------------------------------------------------TEST CLASS BELOW------------------------------------------------------------
public class ExceptionsThunderheadUtilTest{
  public string usrNam {get; set;} //name of user
     public string usrPh {get; set;} //users phone number
     public string usrEm {get; set;} // user email address
     public string dlrNam {get; set;} //dealer name
     public String dlrFax {get; set;} //dealer fax number
     public String dlrEm {get; set;} //dealer email
     public String dlrNum {get; set;}
     public String subj{get; set;}
     public String remrk1{get; set;}
     public String remrk2{get; set;}
     public String remrk3{get; set;}
     public String remrk4{get; set;}
     public String remrk5{get; set;}
     public String remrk6{get; set;}
     public String remrk7{get; set;}
        public String remrk8{get; set;}
     public String remrk9{get; set;}
     public String remrk10{get; set;}
   
   
    public ExceptionsThunderheadUtilTest(){
      Account acc = new Account(name = 'Test Dealer', Inbound_Fax__c='555-555-5255', email_address__c='testdealer@dealer.com', GMF_ACF__c = 'GMF', dealer_number__c='00000');
        insert acc;
       
        User usr = new User(phone = '555-555-5555', firstname ='Test',lastname='One',email = 'test@gmf.com');   
     insert usr;
       
        Deal_Exceptions__c ex = new Deal_Exceptions__c();
     insert ex;
       
        ApexPages.StandardController stc = new ApexPages.StandardController(ex);
        ExceptionsThunderheadUtil eth = new ExceptionsThunderheadUtil(stc);
       
        usrNam = 'test';
        System.assertEquals(usrNam, 'test');
       
  usrEm = 'test2';
        System.assertEquals(usrEm, 'test2');

  dlrNam = 'test3';
        System.assertEquals(dlrNam, 'test3');

  dlrFax = 'test4';
        System.assertEquals(dlrFax, 'test4');

  dlrEm = 'test5';
        System.assertEquals(dlrEm, 'test5'); 
       
        dlrNum = 'test6';
        System.assertEquals(dlrNum, 'test6');
       
        usrPh = 'test7';
        System.assertEquals(usrPh, 'test7');
       
        subj = 'test8';
        System.assertEquals(subj, 'test8');
       
        remrk1 = 'test9';
        System.assertEquals(remrk1, 'test9');
       
        remrk2 = 'test10';
        System.assertEquals(remrk2, 'test10');
       
        remrk3 = 'test11';
        System.assertEquals(remrk3, 'test11');
       
        remrk4 = 'test12';
        System.assertEquals(remrk4, 'test12');
       
        remrk5 = 'test13';
        System.assertEquals(remrk5, 'test13');
       
        remrk6 = 'test14';
        System.assertEquals(remrk6, 'test14');
       
        remrk7 = 'test15';
        System.assertEquals(remrk7, 'test15');
       
        remrk8 = 'test16';
        System.assertEquals(remrk8, 'test16');
       
        remrk9 = 'test17';
        System.assertEquals(remrk9, 'test17');
       
        remrk10 = 'test18';
        System.assertEquals(remrk10, 'test18');
       
        
       
        eth.createEmail();
        eth.createFax();
       
       
    }




ANY ADVISE??




Hi, I am trying to sync my contact on with my account owner but entering the dealer number in through a vf page and passing it to a SOQL query in apex. here is my code:

Page:<apex:page standardController="Contact" extensions="DealerContactOwnerSync" >
  <apex:form >
      <tabel >
          <tr>
              <td></td><td>Enter Dealer Number:<apex:inputText value="{!dlrNum}" /></td><br/>
          </tr>
          <tr>
              <td><apex:commandButton value="Sync This Dealer" action="{!dealershipSync}"/></td>
              <td></td>
          </tr>
      </tabel>
  </apex:form>
 
</apex:page>

Controller: 

public string dlrNum; //dealer number
public String getdlrNum(){
   
        return dlrNum;
    }
   
   
    public void setdlrNam(String s) {
        dlrNum= s;
    }
   
   
   
  
  
   Public void dealershipSync(){
      
        //String branchNumber = ApexPages.currentPages.getParameters.get("branch number");

        for(Contact c : [SELECT account.OwnerId, account.Id, account.branch_number__c, account.owner.isActive, account.Active__c, account.Name, account.GMF_ACF__c, Id, OwnerId , Name FROM Contact where end_date__c = null and CreatedDate >= 2008-10-03T00:00:00Z and account.recordtypeid ='01230000000DD54AAG' and account.owner.House_Account__C = false and account.owner.isActive = true  and account.active__c = 'Y' and account.dealer_number__c =:dlrNum order by account.LastModifiedDate limit :iContactBatchSize] ){
                System.debug('Dealer Number is:***************** ' + dlrNum);
                if(c.OwnerID != c.account.OwnerID){
                    Contact mContact = new Contact();
Can someone please assist. I am trying to query for ALL Opportunities and trying to make all the Opp owners sync up with the Account owner:

global class DealerDealOwnerSync implements Database.Batchable<sObject>{
   
    String jbrooks = [SELECT Alias, Id FROM User where alias = 'jbrook7'].id;
    String api = [SELECT Alias, Id FROM User where alias = 'SFAPI'].id;
    String wendy = [SELECT Alias, Id FROM User where alias = 'wkrame1'].id;
    String dwetl = [SELECT Alias, Id FROM User where alias = 'DWETL'].id;
    String ActRecTypeID = [SELECT Name, Id, DeveloperName, SobjectType FROM RecordType where SobjectType = 'Account' and Name = 'Activated'].Id;
    Integer iSize = 0;
   
   
    //TESTING FROM A BUTTON   
    public DealerDealOwnerSync(ApexPages.StandardController stdController)
    {        
      //clsContactOwnerSync();     

    }
   
    public DealerDealOwnerSync()
    {        

 
    }
   
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
      return Database.getQueryLocator('Select Id, OwnerId, Name, CloseDate,Account.OwnerId, Account.Id,Account.Owner.IsActive,Account.Active__c, Account.Name, Account.GMF_ACF__c from Opportunity where stagename != \'DECLINE,WITHDRW\' and Account.recordtypeid = \'01230000000DD54AAG\' and account.owner.House_Account__c = false and account.owner.isActive = true and Account.LastModifiedDate = Last_Month and Account.LastModifiedById = :wendy and Account.Active__c = \'Y\''); // Select Id, OwnerId, Name, CloseDate,Account.OwnerId, Account.Id,Account.Owner.IsActive,Account.Active__c, Account.Name, Account.GMF_ACF__c from Opportunity where stagename != \'DECLINE,WITHDRW\' and Account.recordtypeid = \'01230000000DD54AAG\' and account.owner.House_Account__c = false and account.owner.isActive = true and Account.LastModifiedDate = Last_Month and Account.LastModifiedById = :wendy and Account.Active__c = \'Y\'
    }
   
    global void execute(Database.BatchableContext BC, List<sObject> scope){
        List<Opportunity> dealsToUpdate = new List<Opportunity>();
        for(sObject obj : [Select Id, OwnerId, Name, CloseDate,Account.OwnerId, Account.Id,Account.Owner.IsActive,Account.Active__c, Account.Name, Account.GMF_ACF__c from Opportunity where stagename != 'DECLINE,WITHDRW' and Account.recordtypeid = :ActRecTypeID and account.owner.House_Account__c = false and account.owner.isActive = true and Account.LastModifiedDate = Last_Month and Account.LastModifiedById = :wendy and Account.Active__c = 'Y']){
            Account a = (Account)obj.getSObject('Account');
            /*Opportunity o;
            Account a;*/
            Opportunity[] oppOne = a.getSObjects('Opportunities');
            if(oppOne != null){
                for(Opportunity o: a.opportunities){
                    if(o.OwnerID != a.OwnerID){ 
                        Opportunity mOpportunity = new Opportunity();
                        mOpportunity.Id = o.Id;
                        mOpportunity.OwnerID = a.OwnerID;
                        dealsToUpdate.add(mOpportunity);
                       
                        iSize = iSize + 1;
                        system.debug('**************ISIZE:' +iSize);
                       
                        if(iSize == 1000)
                        {
                            update dealsToUpdate;
                            System.debug('********UPDATE COUNT: ' + iSize);
                            dealsToUpdate = new List<Opportunity>();
                            iSize = 0;
                        }             
                    }
                }
             }
          }
        
             if(iSize < 1000)
             {
                 update dealsToUpdate;
                 System.debug('********UPDATE COUNT: ' + iSize);
                 dealsToUpdate = new List<Opportunity>();
                 iSize = 0;
             }
       
    }

    global void finish(Database.BatchableContext BC)
    {
        //ID d = Database.executeBatch(new DealerDealOwnerSync(),100);
    }
   
   
}


I do not know why i am getting this error, here is my code, help please:

global class DealerDealOwnerSync implements Database.Batchable<sObject>{
    //TESTING FROM A BUTTON
    public DealerDealOwnerSync(ApexPages.StandardController stdController)
    {        
      //clsContactOwnerSync();
     

    }
     public DealerDealOwnerSync()
   {        

 
   }
  
    String wendy = [SELECT Alias, Id FROM User where alias = 'wkrame1'].id;
    String dwetl = [SELECT Alias, Id FROM User where alias = 'DWETL'].id;

    global Database.QueryLocator start(Database.BatchableContext BC)
    {
      return Database.getQueryLocator('Select Id, OwnerId, Name, CloseDate,Account.OwnerId, Account.Id,Account.Owner.IsActive,Account.Active__c, Account.Name, Account.GMF_ACF__c from Opportunity where stagename != \'DECLINE,WITHDRW\' and Account.recordtypeid = \'01230000000DD54AAG\' and account.owner.House_Account__c = false and account.owner.isActive = true and Account.LastModifiedDate = Last_Month and Account.LastModifiedById = :wendy and Account.Active__c = \'Y\''); // Select Id, OwnerId, Name, CloseDate,Account.OwnerId, Account.Id,Account.Owner.IsActive,Account.Active__c, Account.Name, Account.GMF_ACF__c from Opportunity where stagename != \'DECLINE,WITHDRW\' and Account.recordtypeid = \'01230000000DD54AAG\' and account.owner.House_Account__c = false and account.owner.isActive = true and Account.LastModifiedDate = Last_Month and Account.LastModifiedById = :wendy and Account.Active__c = \'Y\'
    }
   
    global void execute(Database.BatchableContext BC, List<sObject> scope){
        List<Opportunity> dealsToUpdate = new List<Opportunity>();
        for(sObject obj : scope){
            Account a = (Account)obj;
            /*Opportunity o;
            Account a;*/
            Opportunity[] oppOne = a.getSObjects('Opportunities');
            if(oppOne != null){
                for(Opportunity o: oppOne){
                    if(o.OwnerID != a.OwnerID){ 
                        Opportunity mOpportunity = new Opportunity();
                        mOpportunity.Id = o.Id;
                        mOpportunity.OwnerID = a.OwnerID;
                        dealsToUpdate.add(mOpportunity);             
                    }
                }
             }
         }
         if(dealsToUpdate.size()>1000)
         {
             update dealsToUpdate;
         }
         if(dealsToUpdate.size()>0)
         {
             update dealsToUpdate;
         }
    }

    global void finish(Database.BatchableContext BC)
    {
        //ID d = Database.executeBatch(new DealerDealOwnerSync(),100);
    }
   
   
}
@future (callout = true)
    public static void clsContactOwnerSync(){
        System.debug('WORKING!!!!!!******:');
        Integer iContactBatchSize = 1000;
        Integer iAccountBatchSize = 3000;
       
       System.debug('WORKING!!!!!!*********');
      
       String ActRecTypeID = [SELECT Name, Id, DeveloperName, SobjectType FROM RecordType where SobjectType = 'Account' and Name = 'Activated'].Id;
       //Sandbox Record Type ID = 01230000000DD54AAG
      
       List<Integer> contactCount = new List<Integer>();

       Integer iSize = 0   ;

    
       //List<Account> accountWithContacts = [SELECT OwnerId, Id, owner.isActive, Active__c, Name, account.GMF_ACF__c, (SELECT Id,OwnerId,Name FROM Contacts where end_date__c = null and CreatedDate >= 2008-10-03T00:00:00Z) FROM Account where  recordtypeid ='01230000000DD54AAG' and account.owner.House_Account__C = false and owner.isActive = true and LastModifiedDate >= Yesterday and active__c = 'Y' limit 8000];
          
      
       //List<Contact> contactsToUpdate = new List<Contact>();
    
       //For loop to iterate through all queried Account records     
       //List<Account> accounts = [Select OwnerId, Id, owner.isActive, Active__c, Name FROM Account where  recordtypeid = :ActRecTypeID and account.owner.House_Account__C = false and owner.isActive = true and LastModifiedDate >= Last_Week and active__c = 'Y' limit 1000]; LastModifiedByID = 00560000000wQdoAAE dwetl  00530000000tfuy apI Serv
        //List<Account> accounts = [SELECT OwnerId, Id, owner.isActive, Active__c, Name, account.GMF_ACF__c, (SELECT Id,OwnerId,Name, CloseDate FROM Opportunities WHERE stagename != 'DECLINE,WITHDRW') FROM Account where  recordtypeid ='01230000000DD54AAG' and account.owner.House_Account__C = false and owner.isActive = true and lastmodifiedbyid = '00560000001268M'  and active__c = 'Y' order by LastModifiedDate limit :iAccountBatchSize];//00560000001268M wendy 00560000000wQdo dwetl
        List<Opportunity> dealsToUpdate = new List<Opportunity>();




        for(Account a: [SELECT OwnerId, Id, owner.isActive, Active__c, Name, account.GMF_ACF__c, (SELECT Id,OwnerId,Name, CloseDate FROM Opportunities WHERE stagename != 'DECLINE,WITHDRW') FROM Account where  recordtypeid ='01230000000DD54AAG' and account.owner.House_Account__C = false and owner.isActive = true and lastmodifiedbyid = '00560000001268M'  and active__c = 'Y' limit :iAccountBatchSize]){

           //List<Contact> updCont = [Select ownerID, id from Contact WHERE AccountId = :a.id];
           
             for(Opportunity o: a.opportunities){
                if(o.OwnerID != a.OwnerID){   
                   
                                     
                        //c.OwnerID = a.OwnerID;
                       
                        Opportunity mOpportunity = new Opportunity();
                        mOpportunity.Id = o.Id;
                        mOpportunity.OwnerID = a.OwnerID;
                        //Contact updCont = [Select ownerID from Contact where id = :c.id];
                        //updCont.ownerid = a.ownerid;              
                        System.debug('Opportunity Id['+ o.Id +'], Name['+ o.name +']');          
                       
                                     
                        dealsToUpdate.add(mOpportunity);               
                        contactCount.add(1);
                       
                       
                        iSize = iSize + 1;
                       
                       System.debug('iSize = ' + iSize);
                       System.debug('******CLOSE DATE FORMATE*****' + o.CloseDate);
                       
                    if(iSize == iContactBatchSize){
                        update dealsToUpdate;
                        System.debug('********UPDATE COUNT: ' + iSize);
                        dealsToUpdate = new List<Opportunity>();
                        iSize = 0;             
                    }             
               }
            }
        }
       
        if(iSize < iContactBatchSize){
                        update dealsToUpdate;
                        System.debug('********UPDATE COUNT: ' + iSize);
                        dealsToUpdate = new List<Opportunity>();
                        iSize = 0;             
                    }  


   }
}
I do not know why i am getting this error, here is my code, help please:

global class DealerDealOwnerSync implements Database.Batchable<sObject>{
    //TESTING FROM A BUTTON
    public DealerDealOwnerSync(ApexPages.StandardController stdController)
    {        
      //clsContactOwnerSync();
     

    }
     public DealerDealOwnerSync()
   {        

 
   }
  
    String wendy = [SELECT Alias, Id FROM User where alias = 'wkrame1'].id;
    String dwetl = [SELECT Alias, Id FROM User where alias = 'DWETL'].id;

    global Database.QueryLocator start(Database.BatchableContext BC)
    {
      return Database.getQueryLocator('Select Id, OwnerId, Name, CloseDate,Account.OwnerId, Account.Id,Account.Owner.IsActive,Account.Active__c, Account.Name, Account.GMF_ACF__c from Opportunity where stagename != \'DECLINE,WITHDRW\' and Account.recordtypeid = \'01230000000DD54AAG\' and account.owner.House_Account__c = false and account.owner.isActive = true and Account.LastModifiedDate = Last_Month and Account.LastModifiedById = :wendy and Account.Active__c = \'Y\''); // Select Id, OwnerId, Name, CloseDate,Account.OwnerId, Account.Id,Account.Owner.IsActive,Account.Active__c, Account.Name, Account.GMF_ACF__c from Opportunity where stagename != \'DECLINE,WITHDRW\' and Account.recordtypeid = \'01230000000DD54AAG\' and account.owner.House_Account__c = false and account.owner.isActive = true and Account.LastModifiedDate = Last_Month and Account.LastModifiedById = :wendy and Account.Active__c = \'Y\'
    }
   
    global void execute(Database.BatchableContext BC, List<sObject> scope){
        List<Opportunity> dealsToUpdate = new List<Opportunity>();
        for(sObject obj : scope){
            Account a = (Account)obj;
            /*Opportunity o;
            Account a;*/
            Opportunity[] oppOne = a.getSObjects('Opportunities');
            if(oppOne != null){
                for(Opportunity o: oppOne){
                    if(o.OwnerID != a.OwnerID){ 
                        Opportunity mOpportunity = new Opportunity();
                        mOpportunity.Id = o.Id;
                        mOpportunity.OwnerID = a.OwnerID;
                        dealsToUpdate.add(mOpportunity);             
                    }
                }
             }
         }
         if(dealsToUpdate.size()>1000)
         {
             update dealsToUpdate;
         }
         if(dealsToUpdate.size()>0)
         {
             update dealsToUpdate;
         }
    }

    global void finish(Database.BatchableContext BC)
    {
        //ID d = Database.executeBatch(new DealerDealOwnerSync(),100);
    }
   
   
}
I am trying to see why this error is occuring for my query. Help would be greatly appreciated.

 List<ContentVersion> cv = [Select Title, portal_effective_date__c, Portal_Effective_Until_Date__c,description, filetype, createddate, isLatest, id, brand__c, state__c, region__c, 
                                           dealer__c from contentversion where ContentDocumentId in (SELECT ContentDocumentId FROM ContentWorkspaceDoc WHERE ContentWorkspaceId = :workspaceId) 
                                           and (Brand__C ='' and region__C = '' and state__c ='') OR region__C = :selRegion OR state__c = :acc.Physical_State__c OR 
                                           (region__C = :selRegion and state__c = :acc.Physical_State__c) and isLatest = true order by Title ASC];
I created a VF page to mock the notes and attachments related list. Now i have it to where the attachments are inserted on top of the notes. How can I get them  sorted by created date to make them mix in with each other instead of attachments being on top and notes being underneath. Any help is appreciated. Thanks.

global class NotesAttachment{
   
    public List<Note> n1 {get;set;}
    public List<Tuple> combinations{get;set;}
    public string ecid{get;set;}
    public string dcid{get;set;}
    public Datetime CreatedDate;
    String strid = System.currentPagereference().getParameters().get('id');
    public sObject Tuppy;   
    public List<Tuple> pageCombinations {get;set;}
    private Integer pageNumber;
    private Integer PageSize;
    private Integer totalPageNumber;
   
   
   
    public Integer getPageNumber(){
       return pageNumber;
    }
    public Integer getPageSize(){
       return pageSize;
    }
    public Boolean getPreviousButtonEnabled(){
           return !(pageNumber> 1);
   
    }
   
    public Integer getTotalPageNumber(){
       if(totalPageNumber == 0 && combinations != null){

        totalPageNumber = combinations.size() / pageSize;
        Integer mod = combinations.size() - (totalPageNumber * pageSize);
        if(mod > 0)
        totalPageNumber++;
        }
    return totalPageNumber;
    }
   
  
   
    public NotesAttachment(ApexPages.StandardController stdController)
     {
        
       //rlucas Paging
       pageNumber = 0;
       totalPageNumber = 0;
       pageSize = 7;
       ViewData();  

    }
   
    //rlucas view note/attachment
    public PageReference ViewData()
    {
        combinations = null;
        totalPageNumber = 0;
        BindData(1);
        return null;
    }
    private void BindData(Integer newPageIndex){
    try{
        //if(combinations == null)
        combinations = new List<Tuple>();
  
        Tuple tr;
        List<Attachment> atts =[SELECT Id, Name, createdbyid, createdDate, lastmodifieddate, ContentType, BodyLength, parentID FROM Attachment where parentid=:ApexPages.currentPage().getParameters().get('Id') order by createddate desc];
        List<Note> nt = [select Body, CreatedById, createdDate,Id, Title, parentID, LastModifieddate from Note where parentid=:ApexPages.currentPage().getParameters().get('Id') order by createdDate desc];
        for(Attachment att : atts){
                //Instantiating the wrapper sObject
                tr = new Tuple();
               
                //Assigning the wrapper variables
                tr.title = att.Name;
                tr.parentID = att.parentID;
                tr.CreatedById = att.CreatedById;
                tr.body = att.ContentType;
                tr.id = att.id;
                tr.LastModifieddate = att.LastModifieddate;
           
                //*Add everything to the List then and there*/
                combinations.add(tr);
            
        } 
         
      
        for(Note con : nt){
            tr = new Tuple();
            tr.title = con.title;
            tr.parentID = con.parentID;
            tr.CreatedById = con.CreatedById;
            tr.body = con.Body;
            tr.id = con.id;
            tr.LastModifieddate = con.LastModifieddate;
           
            /*Add the TableRow to the List then and there*/
            combinations.add(tr);
       }
  
       pageCombinations = new List<Tuple>();
       Transient Integer counter = 0;
       Transient Integer min = 0;
       Transient Integer max = 0;
       if(newPageIndex > pageNumber){
            min = pageNumber * pageSize;
            max = newPageIndex * pageSize;
        } else {
           max = newPageIndex * pageSize;
           min = max - pageSize;
        }
        for(Tuple t : combinations){
           counter ++;
           if(counter > min && counter <=max)
           pageCombinations.add(t);
        }
        pageNumber = newPageIndex;
        if(pageCombinations == null || pageCombinations.size() <= 0)
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'Data not available for this view.'));
    }
    catch(Exception ex)
    {
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,ex.getMessage()));
    }
    }
   
    public Boolean getNextButtonDisabled(){
       if(combinations == null) return true;
       else
       return((pageNumber * pageSize) >= combinations.size());

    }
    public PageReference nextBtnClick(){
        BindData(pageNumber + 1);
    return null;
    }
    public PageReference previousBtnClick(){
        BindData(pageNumber - 1);
    return null;

    }
   
   
   
    //wrapper class
    global class Tuple
   {
     
      public String id {get; set;}
      public String body  {get; set;}
      public String Title {get; set;}
      public String parentID {get; set;}
      public DateTime LastModifieddate{get; set;}
      public String createdbyid  {get; set;}
      public DateTime CreatedDate {get; set;}
      public String Name {get; set;}
      public String ContentType {get; set;}

    }
   
    public NotesAttachment(){
        combinations = new List<Tuple>();
      
       
    }
I have created a queue that holds data in an object in Salesforce. I have researched others who have had some similar issues but nothing is helping so far. Here is the code for it. I am just not sure how to test it, I have have the code that i tried to test it below as well. Can anyone please help me out and not just send me to a link?

Controller:
public class CreateNewExceptionFromCures{
   
    public String ActRecTypeID = [SELECT Name, Id, DeveloperName, SobjectType FROM RecordType where SobjectType = 'Deal_Exceptions__c' and developerName = 'retail'].Id;
     
       
    //Create method for button to pass thru
    public CreateNewExceptionFromCures(ApexPages.StandardController stdController){
       
        //List deal = Query id, appNum from Cure where id = id of cure page
       
    }  

    //Create blank method{}
    public CreateNewExceptionFromCures(){}

   
   
  
    //create void method to populate field
    public PageReference hello1(){
       
        List<Cure__c> deal = [SELECT Id, Application_Number__c, Applicant_Name__c FROM CURE__c WHERE id = :ApexPages.currentPage().getParameters().get('Id')];
     List<Opportunity> opp = [Select ID, Application_number__c From Opportunity where Application_number__c = :deal[0].Application_number__c];
        
     //exCat = Query for category from Exception Category with description other
     List<Exception_Category__c> exCat = [SELECT Exception_Category_Description__c, Id, Exception_Category_Code__c, Name FROM Exception_Category__c where Exception_Category_Code__c = '99'];
       
     //create new exception record and populate the source field = cure
     Deal_Exceptions__c d = new Deal_Exceptions__c(Opportunity__c = opp[0].ID, Source__c = 'Cure', Category__c = exCat[0].id); //opp, category and recordype is required
           
        System.debug('CATEGORY IS*******: '+ d.category__c);       
        insert d;         
                                 
  PageReference reference=new PageReference('https://cs20.salesforce.com/'+ d.id);
        //PageReference reference = new ApexPages.StandardController(d).view();
       
  reference.setRedirect(true);
        return reference;
    }
}

--------------------------------------------------------------------TEST CLASS----------------------------------------------

@isTest
public class CreateNewExceptionFromCuresTest{
    public CreateNewExceptionFromCuresTest(){
      
        CreateNewExceptionFromCures ne = new CreateNewExceptionFromCures();
       system.assertEquals(page.success, ne.hello1());
      
        Cure__c cur = new Cure__c();
      
        Deal_Exceptions__c d = new Deal_Exceptions__c();
        ApexPages.StandardController std = new ApexPages.StandardController(d);
        CreateNewExceptionFromCures thecontroller1 = new CreateNewExceptionFromCures(std);
        thecontroller1.hello1();
       
    }
   
}
I have created a queue that holds data in an object in Salesforce. I have researched others who have had some similar issues but nothing is helping so far. Here is the code for it. I am just not sure how to test it, I have have the code that i tried to test it below as well. Can anyone please help me out.

public class ExceptionsThunderheadUtil { //create apex class ExceptionsEmailtoThunderhead
    List<User> usr = [SELECT id, alias, phone, name,email FROM User WHERE id = :UserInfo.getUserId()];
    public string emRecip;
    public string emSend;
    public string emSub; //email subject
    public string usrNam; //name of user
    public string usrPh; //users phone number
    public string usrEm; // user email address
    public string dlrNam; //dealer name
    public String dlrFax; //dealer fax number
    public String dlrEm; //dealer email
    public String dlrNum;
    public String subj;
    public String remrk1;
    public String remrk2;
    public String remrk3;
    public String remrk4;
    public String remrk5;
    public String remrk6;
    public String remrk7;
    public String remrk8;
    public String remrk9;
    public String remrk10;
  
  
    /*Not Sure if remarks are being prepopulated
    public decimal AcqFee;
    public decimal FincAmt;
    public decimal FlatFee;
    public decimal PartPct;
    public decimal PartAmt;
    public string reqProg;
    public string fieldLabel;*/
  
  
  
  
    //TESTING FROM A BUTTON
    public ExceptionsThunderheadUtil(ApexPages.StandardController stdController)
    {     
            //Select user info
            List<User> usr = [SELECT id, alias, phone, name,email FROM User WHERE id = :UserInfo.getUserId()];
          
            usrNam = usr[0].name;
          
            usrPh = usr[0].phone;
          
            usrEm =  usr[0].email;
          
            //select dealer fields
            List<Deal_Exceptions__c> ex = [SELECT Id, Application_Number__c, Dealer_Name__c FROM Deal_Exceptions__c WHERE id = :ApexPages.currentPage().getParameters().get('Id')];
            List<Account> acc = [Select ID, name, Inbound_Fax__c, Email_Address__c,Dealer_Number__c From Account where name = :ex[0].Dealer_Name__c];
          
            dlrNam = acc[0].name;
            //dlrFax = acc[0].Inbound_Fax__c;
            dlrFax = '877-567-2831';
            //dlrEm = acc[0].Email_Address__c;
            dlrEm = 'jamie.swingle@gmfinancial.com';
            dlrNum = acc[0].dealer_number__c;
          
          
            Thunderhead_Queue_Outbound__c rec = new Thunderhead_Queue_Outbound__c();

    }
  
    public ExceptionsThunderheadUtil()
    {       


    }
  
    public String getDlrNum(){
  
        return dlrNum;
    }
  
    public void setDlrNum(String s) {
        dlrNum = s;
    }
  
    public String getUsrNam(){
  
        return usrNam;
    }
  
    public void setUsrNam(String s) {
        usrNam = s;
    }
  
    public String getUsrPh(){
  
        return usrPh;
    }
  
     public void setUsrPh(String s) {
        UsrPh = s;
    }
  
    public String getUsrEm(){
  
        return usrEm;
    }
  
    public void setUsrEm(String s) {
        UsrEm= s;
    }
  
    public String getdlrNam(){
  
        return dlrNam;
    }
  
  
    public String getdlrFax(){
  
        return dlrFax;
    }
  
    public String getDlrEm(){
  
        return dlrEm;
    
    }
  
    public void setDlrEm(String s){
  
        dlrEm = s;
      
    }
  
    public void setdlrNam(String s) {
        dlrNam= s;
    }
  
      public void setdlrFax(String s) {
        dlrFax = s;
    }
  
    public String getSubj(){
  
        return subj;
      
    }
  
    public void setSubj(String s){
  
        subj = s;
      
    }
  
    public String getRemrk1(){
  
        return remrk1;
      
    }
    public void setRemrk1(string a){
  
        remrk1 =a;
      
    }
  
    public String getRemrk2(){
  
        return remrk2;
      
    }
    public void setRemrk2(string b){remrk2 =b;}
  
    public String getRemrk3(){
  
        return remrk3;
      
    }
    public void setRemrk3(string s){remrk3 =s;}
  
    public String getRemrk4(){return remrk4;}
    public void setRemrk4(string s){remrk4 =s;}
  
    public String getRemrk5(){return remrk5;}
    public void setRemrk5(string s){remrk5 =s;}
  
    public String getRemrk6(){return remrk6;}
    public void setRemrk6(string s){remrk6 =s;}
  
    public String getRemrk7(){return remrk7;}
    public void setRemrk7(string s){remrk7 =s;}
  
    public String getRemrk8(){return remrk8;}
    public void setRemrk8(string s){remrk8 =s;}
  
    public String getRemrk9(){return remrk9;}
    public void setRemrk9(string s){remrk9 =s;}
  
    public String getRemrk10(){return remrk10;}
    public void setRemrk10(string s){remrk10 =s;}
  
    public PageReference createEmail(){
        //List<Deal_Exceptions__c> ex = [SELECT id, Application_Number__c, Dealer_Name__c FROM Deal_Exceptions__c where id = :exp[0].id];
        //List<Account> acc = [Select ID, name From Account where name = :ex[0].Dealer_Name__c];
        List<Deal_Exceptions__c> ex = [SELECT Id, Application_Number__c, Dealer_Name__c FROM Deal_Exceptions__c WHERE id = :ApexPages.currentPage().getParameters().get('Id')];
        List<Account> acc = [Select ID, name, Inbound_Fax__c, email_address__c, GMF_ACF__c, dealer_number__c  From Account where name = :ex[0].Dealer_Name__c];
        Thunderhead_Queue_Outbound__c em = new Thunderhead_Queue_Outbound__c();// create record in Thunderhead_Queue_Outbound__c
        em.Application_Number__c = ex[0].Application_Number__c;
        em.Dealer_Name__c = ex[0].Dealer_Name__c;
        em.Email_from__c = usr[0].email;
        //em.Email_to__c = acc[0].email_address__c;
        em.Email_to__c = 'jamie.swingle@gmfinancial.com';
        em.dealer_number__c = acc[0].dealer_number__c;
        em.subject__c = subj;
        em.remarks_1__c = remrk1;
        em.remarks_2__c = remrk2;
        em.remarks_3__c = remrk3;
        em.remarks_4__c = remrk4;
        em.remarks_5__c = remrk5;
        em.remarks_6__c = remrk6;
        em.remarks_7__c = remrk7;
        em.remarks_8__c = remrk8;
        em.remarks_9__c = remrk9;
        em.remarks_10__c = remrk10;
        em.Brand_Code__c = acc[0].GMF_ACF__c;
        em.Channel_Indicator__c = 'E';
        em.Letter_Type_Code__c = 'POSTFUND';
        em.Need_To_Send__c = true;
      
        insert em;
      
        PageReference reference=new PageReference('https://cs20.salesforce.com/'+ em.id);
        reference.setRedirect(true);

        return reference;
    }
  
  
    public PageReference createFax(){
          
        List<Deal_Exceptions__c> ex = [SELECT id, Application_Number__c, Dealer_Name__c FROM Deal_Exceptions__c WHERE id =:ApexPages.currentPage().getParameters().get('Id')];
        List<Account> acc = [Select ID, name, Inbound_Fax__c, email_address__c, GMF_ACF__c, Dealer_Number__c  From Account where name = :ex[0].Dealer_Name__c];
        ThunderHead_Queue_Outbound__c fx = new ThunderHead_Queue_Outbound__c();
        fx.Application_Number__c = ex[0].Application_Number__c;
        fx.Dealer_Name__c = ex[0].Dealer_Name__c;
        fx.dealer_number__c = acc[0].dealer_number__c;
      
        //Check Deal and Dealer record to grab this info.
      
        fx.Brand_Code__c = acc[0].GMF_ACF__c;
        fx.Channel_Indicator__c = 'F';
        fx.Fax_From__c = usr[0].name;
        //fx.Fax_Number__c = acc[0].Inbound_Fax__c;
        fx.Fax_To__c = ex[0].Dealer_Name__c;
        fx.Fax_Number__c = '877-567-2831';
        fx.Letter_Type_Code__c = 'POSTFUND';
        fx.Need_To_Send__c = true;
        fx.remarks_1__c = remrk1;
        fx.remarks_2__c = remrk2;
        fx.remarks_3__c = remrk3;
        fx.remarks_4__c = remrk4;
        fx.remarks_5__c = remrk5;
        fx.remarks_6__c = remrk6;
        fx.remarks_7__c = remrk7;
        fx.remarks_8__c = remrk8;
        fx.remarks_9__c = remrk9;
        fx.remarks_10__c = remrk10;
  
        insert fx;
      
        PageReference reference=new PageReference('https://cs20.salesforce.com/'+ fx.id);
        reference.setRedirect(true);

        return reference;
      
    }
  
    //for visualforce page remark counter
    Integer count = 1;
                      
    public PageReference incrementCounter() {
            if(count <10){
            count++;}
            return null;
    }
                  
    public Integer getCount() {
        return count;
    }
}

-----------------------------------------------------------TEST CLASS BELOW------------------------------------------------------------
public class ExceptionsThunderheadUtilTest{
  public string usrNam {get; set;} //name of user
     public string usrPh {get; set;} //users phone number
     public string usrEm {get; set;} // user email address
     public string dlrNam {get; set;} //dealer name
     public String dlrFax {get; set;} //dealer fax number
     public String dlrEm {get; set;} //dealer email
     public String dlrNum {get; set;}
     public String subj{get; set;}
     public String remrk1{get; set;}
     public String remrk2{get; set;}
     public String remrk3{get; set;}
     public String remrk4{get; set;}
     public String remrk5{get; set;}
     public String remrk6{get; set;}
     public String remrk7{get; set;}
        public String remrk8{get; set;}
     public String remrk9{get; set;}
     public String remrk10{get; set;}
   
   
    public ExceptionsThunderheadUtilTest(){
    
       
        ExceptionsThunderheadUtil controller = new ExceptionsThunderheadUtil();
        String nextPage = controller.createEmail().getUrl();
       
        // Verify that page fails without parameters
        System.assertEquals('/apex/failure?error=noParam', nextPage);
       
        Account acc = new Account(name = 'Test Dealer', Inbound_Fax__c='555-555-5255', email_address__c='testdealer@dealer.com', GMF_ACF__c = 'GMF', dealer_number__c='00000');
        insert acc;
        List<Account> accList = [Select ID From Account Limit 1];
       
        User usr = new User(phone = '555-555-5555', firstname ='Test',lastname='One',email = 'test@gmf.com');   
     insert usr;
        List<User> usrList = [Select ID From User Limit 1];
               
        Deal_Exceptions__c ex = new Deal_Exceptions__c();
     insert ex;
        List<Deal_Exceptions__c> exList = [Select ID From Deal_Exceptions__c Limit 1];
       
        ApexPages.StandardController stc = new ApexPages.StandardController(ex);
        ExceptionsThunderheadUtil eth = new ExceptionsThunderheadUtil(stc);
       
        controller = new ExceptionsThunderheadUtil();
       
        controller.UsrNam = 'test';
        System.assertEquals(usrNam, 'test');
       
  controller.usrEm = 'test2';
        System.assertEquals(usrEm, 'test2');

  controller.dlrNam = 'test3';
        System.assertEquals(dlrNam, 'test3');

  controller.dlrFax = 'test4';
        System.assertEquals(dlrFax, 'test4');

  controller.dlrEm = 'test5';
        System.assertEquals(dlrEm, 'test5'); 
       
        controller.dlrNum = 'test6';
        System.assertEquals(dlrNum, 'test6');
       
        controller.usrPh = 'test7';
        System.assertEquals(usrPh, 'test7');
       
        controller.subj = 'test8';
        System.assertEquals(subj, 'test8');
       
        controller.remrk1 = 'test9';
        System.assertEquals(remrk1, 'test9');
       
        controller.remrk2 = 'test10';
        System.assertEquals(remrk2, 'test10');
       
        controller.remrk3 = 'test11';
        System.assertEquals(remrk3, 'test11');
       
        controller.remrk4 = 'test12';
        System.assertEquals(remrk4, 'test12');
       
        controller.remrk5 = 'test13';
        System.assertEquals(remrk5, 'test13');
       
        controller.remrk6 = 'test14';
        System.assertEquals(remrk6, 'test14');
       
        controller.remrk7 = 'test15';
        System.assertEquals(remrk7, 'test15');
       
        controller.remrk8 = 'test16';
        System.assertEquals(remrk8, 'test16');
       
        controller.remrk9 = 'test17';
        System.assertEquals(remrk9, 'test17');
       
        controller.remrk10 = 'test18';
        System.assertEquals(remrk10, 'test18');
       
        nextPage = controller.createEmail().getUrl();
       
        // Verify that the success page displays
        System.assertEquals('/apex/success', nextPage);
        
       
        eth.createEmail();
        eth.createFax();
       
       
    }
}
I have created a queue that holds data in an object in Salesforce. Here is the code for it. I am just not sure how to test it, I have have the code that i tried to test it below as well. Can anyone please help me out.

public class ExceptionsThunderheadUtil { //create apex class ExceptionsEmailtoThunderhead
    List<User> usr = [SELECT id, alias, phone, name,email FROM User WHERE id = :UserInfo.getUserId()];
    public string emRecip;
    public string emSend;
    public string emSub; //email subject
    public string usrNam; //name of user
    public string usrPh; //users phone number
    public string usrEm; // user email address
    public string dlrNam; //dealer name
    public String dlrFax; //dealer fax number
    public String dlrEm; //dealer email
    public String dlrNum;
    public String subj;
    public String remrk1;
    public String remrk2;
    public String remrk3;
    public String remrk4;
    public String remrk5;
    public String remrk6;
    public String remrk7;
    public String remrk8;
    public String remrk9;
    public String remrk10;
   
   
    /*Not Sure if remarks are being prepopulated
    public decimal AcqFee;
    public decimal FincAmt;
    public decimal FlatFee;
    public decimal PartPct;
    public decimal PartAmt;
    public string reqProg;
    public string fieldLabel;*/
   
   
   
   
    //TESTING FROM A BUTTON
    public ExceptionsThunderheadUtil(ApexPages.StandardController stdController)
    {      
            //Select user info
            List<User> usr = [SELECT id, alias, phone, name,email FROM User WHERE id = :UserInfo.getUserId()];
           
            usrNam = usr[0].name;
           
            usrPh = usr[0].phone;
           
            usrEm =  usr[0].email;
           
            //select dealer fields
            List<Deal_Exceptions__c> ex = [SELECT Id, Application_Number__c, Dealer_Name__c FROM Deal_Exceptions__c WHERE id = :ApexPages.currentPage().getParameters().get('Id')];
            List<Account> acc = [Select ID, name, Inbound_Fax__c, Email_Address__c,Dealer_Number__c From Account where name = :ex[0].Dealer_Name__c];
           
            dlrNam = acc[0].name;
            //dlrFax = acc[0].Inbound_Fax__c;
            dlrFax = '877-567-2831';
            //dlrEm = acc[0].Email_Address__c;
            dlrEm = 'jamie.swingle@gmfinancial.com';
            dlrNum = acc[0].dealer_number__c;
           
           
            Thunderhead_Queue_Outbound__c rec = new Thunderhead_Queue_Outbound__c();

    }
   
    public ExceptionsThunderheadUtil()
    {        

 
    }
   
    public String getDlrNum(){
   
        return dlrNum;
    }
   
    public void setDlrNum(String s) {
        dlrNum = s;
    }
   
    public String getUsrNam(){
   
        return usrNam;
    }
   
    public void setUsrNam(String s) {
        usrNam = s;
    }
   
    public String getUsrPh(){
   
        return usrPh;
    }
   
     public void setUsrPh(String s) {
        UsrPh = s;
    }
   
    public String getUsrEm(){
   
        return usrEm;
    }
   
    public void setUsrEm(String s) {
        UsrEm= s;
    }
   
    public String getdlrNam(){
   
        return dlrNam;
    }
   
   
    public String getdlrFax(){
   
        return dlrFax;
    }
   
    public String getDlrEm(){
   
        return dlrEm;
     
    }
   
    public void setDlrEm(String s){
   
        dlrEm = s;
       
    }
   
    public void setdlrNam(String s) {
        dlrNam= s;
    }
   
      public void setdlrFax(String s) {
        dlrFax = s;
    }
   
    public String getSubj(){
   
        return subj;
       
    }
   
    public void setSubj(String s){
   
        subj = s;
       
    }
   
    public String getRemrk1(){
   
        return remrk1;
       
    }
    public void setRemrk1(string a){
   
        remrk1 =a;
       
    }
   
    public String getRemrk2(){
   
        return remrk2;
       
    }
    public void setRemrk2(string b){remrk2 =b;}
   
    public String getRemrk3(){
   
        return remrk3;
       
    }
    public void setRemrk3(string s){remrk3 =s;}
   
    public String getRemrk4(){return remrk4;}
    public void setRemrk4(string s){remrk4 =s;}
   
    public String getRemrk5(){return remrk5;}
    public void setRemrk5(string s){remrk5 =s;}
   
    public String getRemrk6(){return remrk6;}
    public void setRemrk6(string s){remrk6 =s;}
   
    public String getRemrk7(){return remrk7;}
    public void setRemrk7(string s){remrk7 =s;}
   
    public String getRemrk8(){return remrk8;}
    public void setRemrk8(string s){remrk8 =s;}
   
    public String getRemrk9(){return remrk9;}
    public void setRemrk9(string s){remrk9 =s;}
   
    public String getRemrk10(){return remrk10;}
    public void setRemrk10(string s){remrk10 =s;}
   
    public PageReference createEmail(){
        //List<Deal_Exceptions__c> ex = [SELECT id, Application_Number__c, Dealer_Name__c FROM Deal_Exceptions__c where id = :exp[0].id];
        //List<Account> acc = [Select ID, name From Account where name = :ex[0].Dealer_Name__c];
        List<Deal_Exceptions__c> ex = [SELECT Id, Application_Number__c, Dealer_Name__c FROM Deal_Exceptions__c WHERE id = :ApexPages.currentPage().getParameters().get('Id')];
        List<Account> acc = [Select ID, name, Inbound_Fax__c, email_address__c, GMF_ACF__c, dealer_number__c  From Account where name = :ex[0].Dealer_Name__c];
        Thunderhead_Queue_Outbound__c em = new Thunderhead_Queue_Outbound__c();// create record in Thunderhead_Queue_Outbound__c
        em.Application_Number__c = ex[0].Application_Number__c;
        em.Dealer_Name__c = ex[0].Dealer_Name__c;
        em.Email_from__c = usr[0].email;
        //em.Email_to__c = acc[0].email_address__c;
        em.Email_to__c = 'jamie.swingle@gmfinancial.com';
        em.dealer_number__c = acc[0].dealer_number__c;
        em.subject__c = subj;
        em.remarks_1__c = remrk1;
        em.remarks_2__c = remrk2;
        em.remarks_3__c = remrk3;
        em.remarks_4__c = remrk4;
        em.remarks_5__c = remrk5;
        em.remarks_6__c = remrk6;
        em.remarks_7__c = remrk7;
        em.remarks_8__c = remrk8;
        em.remarks_9__c = remrk9;
        em.remarks_10__c = remrk10;
        em.Brand_Code__c = acc[0].GMF_ACF__c;
        em.Channel_Indicator__c = 'E';
        em.Letter_Type_Code__c = 'POSTFUND';
        em.Need_To_Send__c = true;
       
        insert em;
       
        PageReference reference=new PageReference('https://cs20.salesforce.com/'+ em.id);
        reference.setRedirect(true);

        return reference;
    }
   
   
    public PageReference createFax(){
           
        List<Deal_Exceptions__c> ex = [SELECT id, Application_Number__c, Dealer_Name__c FROM Deal_Exceptions__c WHERE id =:ApexPages.currentPage().getParameters().get('Id')];
        List<Account> acc = [Select ID, name, Inbound_Fax__c, email_address__c, GMF_ACF__c, Dealer_Number__c  From Account where name = :ex[0].Dealer_Name__c];
        ThunderHead_Queue_Outbound__c fx = new ThunderHead_Queue_Outbound__c();
        fx.Application_Number__c = ex[0].Application_Number__c;
        fx.Dealer_Name__c = ex[0].Dealer_Name__c;
        fx.dealer_number__c = acc[0].dealer_number__c;
       
        //Check Deal and Dealer record to grab this info.
       
        fx.Brand_Code__c = acc[0].GMF_ACF__c;
        fx.Channel_Indicator__c = 'F';
        fx.Fax_From__c = usr[0].name;
        //fx.Fax_Number__c = acc[0].Inbound_Fax__c;
        fx.Fax_To__c = ex[0].Dealer_Name__c;
        fx.Fax_Number__c = '877-567-2831';
        fx.Letter_Type_Code__c = 'POSTFUND';
        fx.Need_To_Send__c = true;
        fx.remarks_1__c = remrk1;
        fx.remarks_2__c = remrk2;
        fx.remarks_3__c = remrk3;
        fx.remarks_4__c = remrk4;
        fx.remarks_5__c = remrk5;
        fx.remarks_6__c = remrk6;
        fx.remarks_7__c = remrk7;
        fx.remarks_8__c = remrk8;
        fx.remarks_9__c = remrk9;
        fx.remarks_10__c = remrk10;
   
        insert fx;
       
        PageReference reference=new PageReference('https://cs20.salesforce.com/'+ fx.id);
        reference.setRedirect(true);

        return reference;
       
    }
   
    //for visualforce page remark counter
    Integer count = 1;
                       
    public PageReference incrementCounter() {
            if(count <10){
            count++;}
            return null;
    }
                   
    public Integer getCount() {
        return count;
    }
}

-----------------------------------------------------------TEST CLASS BELOW------------------------------------------------------------
public class ExceptionsThunderheadUtilTest{
  public string usrNam {get; set;} //name of user
     public string usrPh {get; set;} //users phone number
     public string usrEm {get; set;} // user email address
     public string dlrNam {get; set;} //dealer name
     public String dlrFax {get; set;} //dealer fax number
     public String dlrEm {get; set;} //dealer email
     public String dlrNum {get; set;}
     public String subj{get; set;}
     public String remrk1{get; set;}
     public String remrk2{get; set;}
     public String remrk3{get; set;}
     public String remrk4{get; set;}
     public String remrk5{get; set;}
     public String remrk6{get; set;}
     public String remrk7{get; set;}
        public String remrk8{get; set;}
     public String remrk9{get; set;}
     public String remrk10{get; set;}
   
   
    public ExceptionsThunderheadUtilTest(){
      Account acc = new Account(name = 'Test Dealer', Inbound_Fax__c='555-555-5255', email_address__c='testdealer@dealer.com', GMF_ACF__c = 'GMF', dealer_number__c='00000');
        insert acc;
       
        User usr = new User(phone = '555-555-5555', firstname ='Test',lastname='One',email = 'test@gmf.com');   
     insert usr;
       
        Deal_Exceptions__c ex = new Deal_Exceptions__c();
     insert ex;
       
        ApexPages.StandardController stc = new ApexPages.StandardController(ex);
        ExceptionsThunderheadUtil eth = new ExceptionsThunderheadUtil(stc);
       
        usrNam = 'test';
        System.assertEquals(usrNam, 'test');
       
  usrEm = 'test2';
        System.assertEquals(usrEm, 'test2');

  dlrNam = 'test3';
        System.assertEquals(dlrNam, 'test3');

  dlrFax = 'test4';
        System.assertEquals(dlrFax, 'test4');

  dlrEm = 'test5';
        System.assertEquals(dlrEm, 'test5'); 
       
        dlrNum = 'test6';
        System.assertEquals(dlrNum, 'test6');
       
        usrPh = 'test7';
        System.assertEquals(usrPh, 'test7');
       
        subj = 'test8';
        System.assertEquals(subj, 'test8');
       
        remrk1 = 'test9';
        System.assertEquals(remrk1, 'test9');
       
        remrk2 = 'test10';
        System.assertEquals(remrk2, 'test10');
       
        remrk3 = 'test11';
        System.assertEquals(remrk3, 'test11');
       
        remrk4 = 'test12';
        System.assertEquals(remrk4, 'test12');
       
        remrk5 = 'test13';
        System.assertEquals(remrk5, 'test13');
       
        remrk6 = 'test14';
        System.assertEquals(remrk6, 'test14');
       
        remrk7 = 'test15';
        System.assertEquals(remrk7, 'test15');
       
        remrk8 = 'test16';
        System.assertEquals(remrk8, 'test16');
       
        remrk9 = 'test17';
        System.assertEquals(remrk9, 'test17');
       
        remrk10 = 'test18';
        System.assertEquals(remrk10, 'test18');
       
        
       
        eth.createEmail();
        eth.createFax();
       
       
    }




ANY ADVISE??




Hi, I am trying to sync my contact on with my account owner but entering the dealer number in through a vf page and passing it to a SOQL query in apex. here is my code:

Page:<apex:page standardController="Contact" extensions="DealerContactOwnerSync" >
  <apex:form >
      <tabel >
          <tr>
              <td></td><td>Enter Dealer Number:<apex:inputText value="{!dlrNum}" /></td><br/>
          </tr>
          <tr>
              <td><apex:commandButton value="Sync This Dealer" action="{!dealershipSync}"/></td>
              <td></td>
          </tr>
      </tabel>
  </apex:form>
 
</apex:page>

Controller: 

public string dlrNum; //dealer number
public String getdlrNum(){
   
        return dlrNum;
    }
   
   
    public void setdlrNam(String s) {
        dlrNum= s;
    }
   
   
   
  
  
   Public void dealershipSync(){
      
        //String branchNumber = ApexPages.currentPages.getParameters.get("branch number");

        for(Contact c : [SELECT account.OwnerId, account.Id, account.branch_number__c, account.owner.isActive, account.Active__c, account.Name, account.GMF_ACF__c, Id, OwnerId , Name FROM Contact where end_date__c = null and CreatedDate >= 2008-10-03T00:00:00Z and account.recordtypeid ='01230000000DD54AAG' and account.owner.House_Account__C = false and account.owner.isActive = true  and account.active__c = 'Y' and account.dealer_number__c =:dlrNum order by account.LastModifiedDate limit :iContactBatchSize] ){
                System.debug('Dealer Number is:***************** ' + dlrNum);
                if(c.OwnerID != c.account.OwnerID){
                    Contact mContact = new Contact();
Can someone please assist. I am trying to query for ALL Opportunities and trying to make all the Opp owners sync up with the Account owner:

global class DealerDealOwnerSync implements Database.Batchable<sObject>{
   
    String jbrooks = [SELECT Alias, Id FROM User where alias = 'jbrook7'].id;
    String api = [SELECT Alias, Id FROM User where alias = 'SFAPI'].id;
    String wendy = [SELECT Alias, Id FROM User where alias = 'wkrame1'].id;
    String dwetl = [SELECT Alias, Id FROM User where alias = 'DWETL'].id;
    String ActRecTypeID = [SELECT Name, Id, DeveloperName, SobjectType FROM RecordType where SobjectType = 'Account' and Name = 'Activated'].Id;
    Integer iSize = 0;
   
   
    //TESTING FROM A BUTTON   
    public DealerDealOwnerSync(ApexPages.StandardController stdController)
    {        
      //clsContactOwnerSync();     

    }
   
    public DealerDealOwnerSync()
    {        

 
    }
   
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
      return Database.getQueryLocator('Select Id, OwnerId, Name, CloseDate,Account.OwnerId, Account.Id,Account.Owner.IsActive,Account.Active__c, Account.Name, Account.GMF_ACF__c from Opportunity where stagename != \'DECLINE,WITHDRW\' and Account.recordtypeid = \'01230000000DD54AAG\' and account.owner.House_Account__c = false and account.owner.isActive = true and Account.LastModifiedDate = Last_Month and Account.LastModifiedById = :wendy and Account.Active__c = \'Y\''); // Select Id, OwnerId, Name, CloseDate,Account.OwnerId, Account.Id,Account.Owner.IsActive,Account.Active__c, Account.Name, Account.GMF_ACF__c from Opportunity where stagename != \'DECLINE,WITHDRW\' and Account.recordtypeid = \'01230000000DD54AAG\' and account.owner.House_Account__c = false and account.owner.isActive = true and Account.LastModifiedDate = Last_Month and Account.LastModifiedById = :wendy and Account.Active__c = \'Y\'
    }
   
    global void execute(Database.BatchableContext BC, List<sObject> scope){
        List<Opportunity> dealsToUpdate = new List<Opportunity>();
        for(sObject obj : [Select Id, OwnerId, Name, CloseDate,Account.OwnerId, Account.Id,Account.Owner.IsActive,Account.Active__c, Account.Name, Account.GMF_ACF__c from Opportunity where stagename != 'DECLINE,WITHDRW' and Account.recordtypeid = :ActRecTypeID and account.owner.House_Account__c = false and account.owner.isActive = true and Account.LastModifiedDate = Last_Month and Account.LastModifiedById = :wendy and Account.Active__c = 'Y']){
            Account a = (Account)obj.getSObject('Account');
            /*Opportunity o;
            Account a;*/
            Opportunity[] oppOne = a.getSObjects('Opportunities');
            if(oppOne != null){
                for(Opportunity o: a.opportunities){
                    if(o.OwnerID != a.OwnerID){ 
                        Opportunity mOpportunity = new Opportunity();
                        mOpportunity.Id = o.Id;
                        mOpportunity.OwnerID = a.OwnerID;
                        dealsToUpdate.add(mOpportunity);
                       
                        iSize = iSize + 1;
                        system.debug('**************ISIZE:' +iSize);
                       
                        if(iSize == 1000)
                        {
                            update dealsToUpdate;
                            System.debug('********UPDATE COUNT: ' + iSize);
                            dealsToUpdate = new List<Opportunity>();
                            iSize = 0;
                        }             
                    }
                }
             }
          }
        
             if(iSize < 1000)
             {
                 update dealsToUpdate;
                 System.debug('********UPDATE COUNT: ' + iSize);
                 dealsToUpdate = new List<Opportunity>();
                 iSize = 0;
             }
       
    }

    global void finish(Database.BatchableContext BC)
    {
        //ID d = Database.executeBatch(new DealerDealOwnerSync(),100);
    }
   
   
}


@future (callout = true)
    public static void clsContactOwnerSync(){
        System.debug('WORKING!!!!!!******:');
        Integer iContactBatchSize = 1000;
        Integer iAccountBatchSize = 3000;
       
       System.debug('WORKING!!!!!!*********');
      
       String ActRecTypeID = [SELECT Name, Id, DeveloperName, SobjectType FROM RecordType where SobjectType = 'Account' and Name = 'Activated'].Id;
       //Sandbox Record Type ID = 01230000000DD54AAG
      
       List<Integer> contactCount = new List<Integer>();

       Integer iSize = 0   ;

    
       //List<Account> accountWithContacts = [SELECT OwnerId, Id, owner.isActive, Active__c, Name, account.GMF_ACF__c, (SELECT Id,OwnerId,Name FROM Contacts where end_date__c = null and CreatedDate >= 2008-10-03T00:00:00Z) FROM Account where  recordtypeid ='01230000000DD54AAG' and account.owner.House_Account__C = false and owner.isActive = true and LastModifiedDate >= Yesterday and active__c = 'Y' limit 8000];
          
      
       //List<Contact> contactsToUpdate = new List<Contact>();
    
       //For loop to iterate through all queried Account records     
       //List<Account> accounts = [Select OwnerId, Id, owner.isActive, Active__c, Name FROM Account where  recordtypeid = :ActRecTypeID and account.owner.House_Account__C = false and owner.isActive = true and LastModifiedDate >= Last_Week and active__c = 'Y' limit 1000]; LastModifiedByID = 00560000000wQdoAAE dwetl  00530000000tfuy apI Serv
        //List<Account> accounts = [SELECT OwnerId, Id, owner.isActive, Active__c, Name, account.GMF_ACF__c, (SELECT Id,OwnerId,Name, CloseDate FROM Opportunities WHERE stagename != 'DECLINE,WITHDRW') FROM Account where  recordtypeid ='01230000000DD54AAG' and account.owner.House_Account__C = false and owner.isActive = true and lastmodifiedbyid = '00560000001268M'  and active__c = 'Y' order by LastModifiedDate limit :iAccountBatchSize];//00560000001268M wendy 00560000000wQdo dwetl
        List<Opportunity> dealsToUpdate = new List<Opportunity>();




        for(Account a: [SELECT OwnerId, Id, owner.isActive, Active__c, Name, account.GMF_ACF__c, (SELECT Id,OwnerId,Name, CloseDate FROM Opportunities WHERE stagename != 'DECLINE,WITHDRW') FROM Account where  recordtypeid ='01230000000DD54AAG' and account.owner.House_Account__C = false and owner.isActive = true and lastmodifiedbyid = '00560000001268M'  and active__c = 'Y' limit :iAccountBatchSize]){

           //List<Contact> updCont = [Select ownerID, id from Contact WHERE AccountId = :a.id];
           
             for(Opportunity o: a.opportunities){
                if(o.OwnerID != a.OwnerID){   
                   
                                     
                        //c.OwnerID = a.OwnerID;
                       
                        Opportunity mOpportunity = new Opportunity();
                        mOpportunity.Id = o.Id;
                        mOpportunity.OwnerID = a.OwnerID;
                        //Contact updCont = [Select ownerID from Contact where id = :c.id];
                        //updCont.ownerid = a.ownerid;              
                        System.debug('Opportunity Id['+ o.Id +'], Name['+ o.name +']');          
                       
                                     
                        dealsToUpdate.add(mOpportunity);               
                        contactCount.add(1);
                       
                       
                        iSize = iSize + 1;
                       
                       System.debug('iSize = ' + iSize);
                       System.debug('******CLOSE DATE FORMATE*****' + o.CloseDate);
                       
                    if(iSize == iContactBatchSize){
                        update dealsToUpdate;
                        System.debug('********UPDATE COUNT: ' + iSize);
                        dealsToUpdate = new List<Opportunity>();
                        iSize = 0;             
                    }             
               }
            }
        }
       
        if(iSize < iContactBatchSize){
                        update dealsToUpdate;
                        System.debug('********UPDATE COUNT: ' + iSize);
                        dealsToUpdate = new List<Opportunity>();
                        iSize = 0;             
                    }  


   }
}

Hi,

 

There is an old thread here that presents some code to sort a list of sObjects by a field value without using ORDER BY in your query.

 

I recently wanted to do this very thing, so I took a look at that code, but I wasn't satisfied.  I couldn't read the code he presented.  Honestly, it probably works just fine, but since I couldn't read it, I didn't want to use it (and potentially have to maintain it over time).  So I made my own.

 

My implementation is much cleaner and easier to read.  All you have to give it is your List<sObject> and a String representing the field you want to sort on.  It handles Strings, Numbers, and Time type fields, as defined below:

    Strings:  Email, Id, Phone, Picklist (single-select), Reference (Id), String, URL

    Numbers:  Floating types, Integer, Percent

    Time:  Date, Datetime, Time

 

If the field is not of any of those types, the method throws an exception.  It will also fail if the field isn't included on all of the objects in the list.

 

The hard and potentially confusing part of this code is the dynamic behavior it requires to use a string (fieldName) to compare actual values on sObject records.  In the sortByField method, I retrieve the Schema.sObjectField that gets passed through the sort algorithm and used in the comparisons.  The comparison methods need this field to determine the field type so it will do the right kind of comparison (String, Number, or Time).

 

I use quicksort, because a related blog post already had it implemented for me, but you could easily swap out the algorithm for heapsort or something else guaranteed to be nlogn.

 

Here is the code!  I'm very open to suggestions/improvements, so leave a comment if you've got any improvements or if you find any bugs.  I hope this is useful to someone out there!

 

/*
Sorts a list of sObjects, sorted by the value of the specified field
Throws: SortingException
*/
public static void sortByField(List<sObject> objs, String fieldName) {
	if (objs.size() < 2) return;
	Schema.sObjectField field = objs.getsObjectType().getDescribe().fields.getMap().get(fieldName);
if (field == null) throw new SortingException('No such field ' + fieldName); Schema.DescribeFieldResult fieldDesc = field.getDescribe(); if (!fieldDesc.isSortable()) throw new SortingException('Type not sortable: ' + fieldDesc.getType()); quicksortByField(objs, 0, objs.size()-1, field, fieldDesc.gettype()); }
public class SortingException extends Exception {}
/* Implements quicksort on the list of sObjects given */ private static void quicksortByField(List<sObject> a, Integer lo0, Integer hi0, Schema.sObjectField field, Schema.DisplayType type) { Integer lo = lo0; Integer hi = hi0; if (lo >= hi) { return; } else if (lo == hi - 1) { if (compareFields(a[lo], a[hi], field, type) > 0) { sObject o = a[lo]; a[lo] = a[hi]; a[hi] = o; } return; } sObject pivot = a[(lo + hi) / 2]; a[(lo + hi) / 2] = a[hi]; a[hi] = pivot; while (lo < hi) { while (compareFields(a[lo], pivot, field, type) < 1 && lo < hi) { lo++; } while (compareFields(pivot, a[hi], field, type) < 1 && lo < hi) { hi--; } if (lo < hi) { sObject o = a[lo]; a[lo] = a[hi]; a[hi] = o; } } a[hi0] = a[hi]; a[hi] = pivot; quicksortByField(a, lo0, lo-1, field, type); quicksortByField(a, hi+1, hi0, field, type); }
/* Determines the type of primitive the field represents, then returns the appropriate comparison */ private static Integer compareFields(sObject a, sObject b, Schema.sObjectField field, Schema.DisplayType type) { if (type == Schema.DisplayType.Email || type == Schema.DisplayType.Id || type == Schema.DisplayType.Phone || type == Schema.DisplayType.Picklist || type == Schema.DisplayType.Reference || type == Schema.DisplayType.String || type == Schema.DisplayType.URL) { // compareTo method does the same thing as the compare methods below for Numbers and Time // compareTo method on Strings is case-sensitive. Use following line for case-sensitivity
// return String.valueOf(a.get(field)).compareTo(String.valueOf(b.get(field)));
return String.valueOf(a.get(field)).toLowerCase().compareTo(String.valueOf(b.get(field)).toLowerCase()); } else if (type == Schema.DisplayType.Currency || type == Schema.DisplayType.Double || type == Schema.DisplayType.Integer || type == Schema.DisplayType.Percent) { return compareNumbers(Double.valueOf(a.get(field)), Double.valueOf(b.get(field))); } else if (type == Schema.DisplayType.Date || type == Schema.DisplayType.DateTime || type == Schema.DisplayType.Time) { return compareTime(Datetime.valueOf(a.get(field)), Datetime.valueOf(b.get(field))); } else { throw new SortingException('Type not sortable: ' + type); } }
private static Integer compareNumbers(Double a, Double b) { if (a < b) { return -1; } else if (a > b) { return 1; } else { return 0; } }
private static Integer compareTime(Datetime a, Datetime b) { if (a < b) { return -1; } else if (a > b) { return 1; } else { return 0; } }

 

 

Update 2/26/2013:

  • Discovered sort of a bug with String comparisons:  using String.compareTo is case-sensitive.  I personally would prefer a case-insensitive comparison, so I have modified the code to do so.  If you prefer case-sensitivity, you can uncomment the original line of code and use that instead.
  • Since the method is destructive to the original list (changes the order of the elements), I made changed the return type of the method to 'void'.
  • Added error handling in case fieldName is invalid

I have built a visualforce page that renders to an excel. The main structure of the excel is using Tables however I run into a problem when I need to include excel formulas in the table.

 

The main problem I am having is that when I include an excel formula that includes greater than or less than statement, which include a < or >, it causes the visualforce page to throw up the following error:

 

Error: The content of elements must consist of well-formed character data or markup.

 

How can I place my formula in the table without getting this error? Is there a function that will output the text exactly as it is shown without trying to render elements between the < and > characters?

How can I create and call a function in an Apex class that will return a value? I have managed to create a void method that doesn't return, but I need to return a value.

Cheers