• jmburns
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 8
    Replies

Hey guys,

 

Im new to developing in Apex and am running into a problem, I was hoping to find some help!

 

I have a trigger which creates or updates a contact based on information on the parent object (B2B_Lead__c), I am running into the follow error "UpdateContactB2B: System.LimitException: Too many SOQL queries: 101"  Here is my code, I would appreciate any help.

 

 

trigger UpdateContactB2B on B2B_Lead__c (after update)
{
      List<Contact> contacts = new List<Contact>();
     
      if (trigger.isInsert || trigger.isUpdate)
      {
            for (B2B_Lead__c pnc : trigger.new)
                 
            if (pnc.First_Name__c != '' && pnc.Last_Name__c != '')
            {
                  List<Contact> pncContacts = [SELECT Id, FirstName, LastName, Email,
                                                                        Middle_Name__c, MobilePhone, HomePhone,
                                                                        Work_Phone__c, MailingCity, MailingState, MailingStreet,
                                                                        MailingPostalCode, ContactType__c
                                                            FROM Contact WHERE B2B_Lead__c = :pnc.Id];
                       
                  Contact primary = null;
                  Contact secondary = null;
                 
                  // primary contact logic                                                     
                  if (pncContacts != null && pncContacts.size() > 0)
                  {
                        for (Contact c : pncContacts)
                        {
                              if (c.ContactType__c == 'Primary')
                              {
                                    primary = c;
                              }
                             
                              if (c.ContactType__c == 'Co-signer')
                              {
                                    secondary = c;
                              }
                        }
                  }
 
                  if (primary == null)
                  {
                        primary = new Contact(B2B_Lead__c = pnc.Id);
                        primary.FirstName = pnc.First_Name__c;
                        primary.LastName = pnc.Last_Name__c;
                        
                        primary.Email = pnc.Direct_Email__c;
                        
                        primary.Work_Phone__c = pnc.Direct_Phone__c;
                       
                        primary.MailingStreet = pnc.Address__c;
                        primary.MailingCity = pnc.City__c;
                        primary.MailingPostalCode = pnc.Zip_Code__c;
                        primary.MailingState = pnc.State__c;
                        primary.ContactType__c = 'Primary';
                  }
                  else
                  {
                        primary.FirstName = pnc.First_Name__c;
                        primary.LastName = pnc.Last_Name__c;
                       
                        primary.Email = pnc.Direct_Email__c;
                       
                        primary.Work_Phone__c = pnc.Direct_Phone__c;
                        
                        primary.MailingStreet = pnc.Address__c;
                        primary.MailingCity = pnc.City__c;
                        primary.MailingPostalCode = pnc.Zip_Code__c;
                        primary.MailingState = pnc.State__c;
                  }
                       
                  
                       
                  contacts.add(primary);
            }
      }
     
      if (contacts.size() > 0)
      {
            upsert contacts;
      }
}

 

Can some one please help me with test code for this trigger? I am in a crunch and am about to go live with a system and my developer is not available! I would appreciate any help.

 

trigger Set_Doc_Code on dsfs__DocuSign_Envelope_Recipient__c (after update) {
for (dsfs__DocuSign_Envelope_Recipient__c a : Trigger.new) {
a.dsfs__DSER_ContactID__c = a.Receiver__c; }}

 

JB

I need help please! Have deadline and never faced this complex of a data import. We are importing data from an old web based system that we do not have control over

 

In Salesforce:

 

I have 1 Parent object : Clients

 

And 5 related objects via master-detail or lookup:

 

Contact

Client Debt

Payment History

Offers

Financial Profile

 

-----

 

The export from the old system is seperated into similiar objects, 6 individual files.

 

There is one field in common in every excel file : CUSTOMER ID which is the filed that correlated the objects in the old system

 

How do import the custom objects?

 

I accomplished the client file obviously by simply importing it. Contacts I got done by including the CUSTOMER ID in the (Client)  import and then simply exporting the Client ID and CUSTOMER ID and pasting into the excel file (which was sorted exactly the same way with all of the customer id's, so the client id's matched up)

 

The problem is the other files will not match up as some clients do not have debt or offers(or they may have 9 debts) so I cannot simply paste the salesforce id's in. The customer id is unique, but in the case of debts and payments may exist multiple times.

 

 

How do i get this data in?

 

JB

 

 

This class displays all Payment-History__c records associated with Client__c and allows to edit and save. I am trying to create the ability to insert a new line in the table basically an add row functionality. I cannot seem to make it work, here is the original class without the add row function:

 

 

public with sharing class BulkEdit {
    public List<Payment_History__c> payments;
    public Id thePH;
    
  // class constructor 
    public BulkEdit() {
        thePH = ApexPages.currentPage().getParameters().get('id');
        payments = getPayments();
    }
    
  // get all the children for this Client__c
    public List<Payment_History__c> getPayments() {
      payments = [SELECT Name, Payment_Amount__c, Payment_Scheduled_Date__c, Payment_Cleared_Date__c, Payment_Status__c, Fee_Payment__C, Set_Payment__c, Processing_Fee__c
                    FROM Payment_History__c  WHERE Client__r.Id = :thePH];

       return payments;
    }
    
    public PageReference back()
    {      
        return new PageReference('/' + thePH);
    }
    
  // the Save button's method.  This will update both the parent and children records.
    public PageReference savePayments() {
        update payments;
        payments = getPayments();
        
        if (thePH == null)
        {
      return null;
        }
                
        Client__c phToUpdate = [ SELECT Id FROM Client__c WHERE Id = :thePH LIMIT 1];
        update phToUpdate;
        //return new PageReference('/' + thePH);
        
        // refresh current page
        return ApexPages.currentPage();
    }
}

 

 

Here is my attempt at adding the add row function, on this one the ad row function works..but the original function to display and save does not...lol what am i doing wrong????

 

 

public with sharing class BulkEdit {
    public List<Payment_History__c> payments {get; set;}
       public Id thePH;
 
        
  // class constructor 
    public BulkEdit() {
        thePH = ApexPages.currentPage().getParameters().get('id');
        payments = getPayments();
        payments = new List<Payment_History__c>();
        payments.add(new Payment_History__c());

    }
    public void addrow(){
        
        payments.add(new Payment_History__c());  
    }
    
  // get all the children for this Client__c
    public List<Payment_History__c> getPayments() {
      payments = [SELECT Name, Payment_Amount__c, Payment_Scheduled_Date__c, Payment_Cleared_Date__c, Payment_Status__c, Fee_Payment__C, Set_Payment__c, Processing_Fee__c
                    FROM Payment_History__c  WHERE Client__r.Id = :thePH];

       return payments;
    }

    public PageReference back()
    {      
        return new PageReference('/' + thePH);
    }
    
  // the Save button's method.  This will update both the parent and children records.
    public PageReference savePayments() {
        update payments;
        insert payments;
        payments = getPayments();
                             
        if (thePH == null)
        {
      return null;
        }
                
        Client__c phToUpdate = [ SELECT Id FROM Client__c WHERE Id = :thePH LIMIT 1];
        update phToUpdate;
        
        //return new PageReference('/' + thePH);
        
        // refresh current page
        return ApexPages.currentPage();
        
        
    }
    }

 

 

I have received a lot of help form these boards and greatly appreciate the opportunity to learn, my developer is on vaction until monday (shes been gone 2 weeks!) and I am trying to make sure we dont miss our deadline. Thank you for any help!

 

Jason Burns

I have a visual force page and apex class for editing multiple records at once, I am trying to make a button that creates a new record...I have the save function working, but cannot figure out how to create a new record. Any help would be appreciated!

 

Apex Class:

 

 

public with sharing class BulkEdit {
    public List<Payment_History__c> payments;
    public Id thePH;
    
  // class constructor 
    public BulkEdit() {
        thePH = ApexPages.currentPage().getParameters().get('id');
        payments = getPayments();
    }
    
  // get all the children for this Client__c
    public List<Payment_History__c> getPayments() {
      payments = [SELECT Name, Payment_Amount__c, Payment_Scheduled_Date__c, Payment_Cleared_Date__c, Payment_Status__c, Fee_Payment__C, Set_Payment__c, Processing_Fee__c
                    FROM Payment_History__c  WHERE Client__r.Id = :thePH];

       return payments;
    }
    
    public PageReference back()
    {      
        return new PageReference('/' + thePH);
    }
    
  // the Save button's method.  This will update both the parent and children records.
    public PageReference savePayments() {
        update payments;
        payments = getPayments();
        
        if (thePH == null)
        {
      return null;
        }
                
        Client__c phToUpdate = [ SELECT Id FROM Client__c WHERE Id = :thePH LIMIT 1];
        update phToUpdate;
        //return new PageReference('/' + thePH);
        
        // refresh current page
        return ApexPages.currentPage();
    }
}

 

 

VF Page:

 

 

<apex:page controller="BulkEdit" tabStyle="Client__c">

<apex:form id="theForm">
  <apex:pageBlock title="Payment Schedule" mode="edit">

<!-- our Save button tied to our Save method -->
            <apex:pageBlockButtons >
                <apex:commandButton action="{!savePayments}" value="Save"/>
                <apex:commandButton action="{!back}" value="Back to Client Record"/>
            </apex:pageBlockButtons>

<!--
     Here we create a table using the Visualforce tag <apex:pageBlockTable>
     {!payments} calls "getPayments" method in our controller.
     Note: the word "get" in accessor methods is implicit in Visualforce.
     We're also assigning a name variable of "currentPayment" for each accessed record.
     The IDs need to be present to perform the updates but we can keep them
     invisible to our user through rendered="false"
-->
            <apex:pageBlockTable value="{!payments}" var="currentPayment" id="theRepeat">
              <apex:outputText rendered="false">{!currentPayment.Client__r.Id}</apex:outputText>
              <apex:outputText rendered="false">{!currentPayment.Client__c}</apex:outputText>

<!--
     We create our columns, along with headers, for our user worksheet
     Depending on whether or not we want to allow the user to edit a field, we use
     the inputField or outputField tags.
-->
                <apex:column ><apex:facet name="header">Name</apex:facet>
                    <apex:outputField value="{!currentPayment.name}"/>
                </apex:column>
                <apex:column width="80px"><apex:facet name="header">Amount</apex:facet>
                    <apex:inputField value="{!currentPayment.Payment_Amount__c}" style="width:80px"/>
                </apex:column>
                <apex:column ><apex:facet name="header">Sched Date</apex:facet>
                    <apex:inputField value="{!currentPayment.Payment_Scheduled_Date__c}"/>
                </apex:column>
                <apex:column ><apex:facet name="header">Clear Date</apex:facet>
                    <apex:inputField value="{!currentPayment.Payment_Cleared_Date__c}"/>
                </apex:column>
                <apex:column ><apex:facet name="header">Status</apex:facet>
                     <apex:inputField value="{!currentPayment.Payment_Status__c}" style="{!IF((currentPayment.Payment_Status__c = 'Cleared'),'color:green','color:red')}"/>
                </apex:column>
                <apex:column ><apex:facet name="header">Processing Fee</apex:facet>
                    <apex:inputField value="{!currentPayment.Processing_Fee__c}"/>
                </apex:column>
                <apex:column ><apex:facet name="header">Retainer Fee</apex:facet>
                    <apex:inputField value="{!currentPayment.Fee_Payment__c}"/>
                </apex:column>
                <apex:column ><apex:facet name="header">Accumulation</apex:facet>
                    <apex:inputField value="{!currentPayment.Set_Payment__c}"/>
                </apex:column>
                
            </apex:pageBlockTable>
  </apex:pageBlock>
</apex:form>
              <apex:iframe id="xyz" src="/apex/Bulk_Edit_Offer_Payments?id={!$CurrentPage.parameters.Id}"></apex:iframe>

</apex:page>

 

 

 

 

 

Trying to upload this test class, but i am getting an error that apex test coverage is only 74%..which is why im trying to upload this test class lol..... any ideas? I am including the clas it is testing below....

 

 Appreciate any help!!

Thank You

 

@isTest
private class tableSortTest {
  private static void test() {
    Account a = new Account(name='Test');
    insert a;
    List<Task> tasks = new List<Task>{
      new Task(Subject='A Task',ActivityDate=System.Today(),Status='Completed',WhatId=a.id),
      new Task(Subject='Z Task',ActivityDate=System.Today().addDays(-1),Status='Not Started',WhatId=a.id)};
    insert tasks;
    Test.setCurrentPage(Page.Sort); 
    Test.startTest();
    ApexPages.currentPage().getParameters().put('id',a.id);
    tableSort controller = new tableSort();
    System.assertEquals(2,controller.getOpps().size());
    controller.sortField = 'Subject';
    controller.doSort();
    System.assertEquals('A Task',controller.getOpps()[0].Subject);
    controller.doSort();
    System.assertEquals('Z Task',controller.getOpps()[0].Subject);
    controller.sortField='ActivityDate';
    controller.doSort();
    System.assertEquals(System.Today().addDays(-1),controller.getOpps()[0].ActivityDate);
    controller.sortField='Subject';
    controller.doSort();
    System.assertEquals('A Task',controller.getOpps()[0].Subject);
    Test.stopTest();
  }
}

 

public class tableSort {

    public List<Task> opps;
    public Id theT;
    public String sortField {get; set;}
    public String previousSortField {get; set;}
    
      {
        theT = ApexPages.currentPage().getParameters().get('id');
        
    }
    
    public List<Task> getOpps() {
        if(opps == null){
            opps = [select WhatId, Subject, OwnerId, Description, ActivityDate from Task WHERE WhatId = :theT ];
        }
        return opps;
    }
    
    public void doSort(){
        String order = 'asc';
        
        /*This checks to see if the same header was click two times in a row, if so 
        it switches the order.*/
        if(previousSortField == sortField){
            order = 'desc';
            previousSortField = null;
        }else{
            previousSortField = sortField;
        }
       
        //To sort the table we simply need to use this one line, nice!
        superSort.sortList(opps,sortField,order);
    }
}

 

 

 

 

Trying to write test code for this apex class, can some one please help? I have another class to upload and my part-time developer is out of town! I am at 74% can some one PLEASE help me get it up a bit so I can upload my class?

 

 

public class tableSort {

    public List<Task> opps;
    public Id theT;
    public String sortField {get; set;}
    public String previousSortField {get; set;}
    
      {
        theT = ApexPages.currentPage().getParameters().get('id');
        
    }
    
    public List<Task> getOpps() {
        if(opps == null){
            opps = [select WhatId, Subject, OwnerId, Description, ActivityDate from Task WHERE WhatId = :theT ];
        }
        return opps;
    }
    
    public void doSort(){
        String order = 'asc';
        
        /*This checks to see if the same header was click two times in a row, if so 
        it switches the order.*/
        if(previousSortField == sortField){
            order = 'desc';
            previousSortField = null;
        }else{
            previousSortField = sortField;
        }
       
        //To sort the table we simply need to use this one line, nice!
        superSort.sortList(opps,sortField,order);
    }
}

 

 

Thanks in advance to anyone who might help!

 

JB

Hey guys,

 

Im new to developing in Apex and am running into a problem, I was hoping to find some help!

 

I have a trigger which creates or updates a contact based on information on the parent object (B2B_Lead__c), I am running into the follow error "UpdateContactB2B: System.LimitException: Too many SOQL queries: 101"  Here is my code, I would appreciate any help.

 

 

trigger UpdateContactB2B on B2B_Lead__c (after update)
{
      List<Contact> contacts = new List<Contact>();
     
      if (trigger.isInsert || trigger.isUpdate)
      {
            for (B2B_Lead__c pnc : trigger.new)
                 
            if (pnc.First_Name__c != '' && pnc.Last_Name__c != '')
            {
                  List<Contact> pncContacts = [SELECT Id, FirstName, LastName, Email,
                                                                        Middle_Name__c, MobilePhone, HomePhone,
                                                                        Work_Phone__c, MailingCity, MailingState, MailingStreet,
                                                                        MailingPostalCode, ContactType__c
                                                            FROM Contact WHERE B2B_Lead__c = :pnc.Id];
                       
                  Contact primary = null;
                  Contact secondary = null;
                 
                  // primary contact logic                                                     
                  if (pncContacts != null && pncContacts.size() > 0)
                  {
                        for (Contact c : pncContacts)
                        {
                              if (c.ContactType__c == 'Primary')
                              {
                                    primary = c;
                              }
                             
                              if (c.ContactType__c == 'Co-signer')
                              {
                                    secondary = c;
                              }
                        }
                  }
 
                  if (primary == null)
                  {
                        primary = new Contact(B2B_Lead__c = pnc.Id);
                        primary.FirstName = pnc.First_Name__c;
                        primary.LastName = pnc.Last_Name__c;
                        
                        primary.Email = pnc.Direct_Email__c;
                        
                        primary.Work_Phone__c = pnc.Direct_Phone__c;
                       
                        primary.MailingStreet = pnc.Address__c;
                        primary.MailingCity = pnc.City__c;
                        primary.MailingPostalCode = pnc.Zip_Code__c;
                        primary.MailingState = pnc.State__c;
                        primary.ContactType__c = 'Primary';
                  }
                  else
                  {
                        primary.FirstName = pnc.First_Name__c;
                        primary.LastName = pnc.Last_Name__c;
                       
                        primary.Email = pnc.Direct_Email__c;
                       
                        primary.Work_Phone__c = pnc.Direct_Phone__c;
                        
                        primary.MailingStreet = pnc.Address__c;
                        primary.MailingCity = pnc.City__c;
                        primary.MailingPostalCode = pnc.Zip_Code__c;
                        primary.MailingState = pnc.State__c;
                  }
                       
                  
                       
                  contacts.add(primary);
            }
      }
     
      if (contacts.size() > 0)
      {
            upsert contacts;
      }
}

 

This class displays all Payment-History__c records associated with Client__c and allows to edit and save. I am trying to create the ability to insert a new line in the table basically an add row functionality. I cannot seem to make it work, here is the original class without the add row function:

 

 

public with sharing class BulkEdit {
    public List<Payment_History__c> payments;
    public Id thePH;
    
  // class constructor 
    public BulkEdit() {
        thePH = ApexPages.currentPage().getParameters().get('id');
        payments = getPayments();
    }
    
  // get all the children for this Client__c
    public List<Payment_History__c> getPayments() {
      payments = [SELECT Name, Payment_Amount__c, Payment_Scheduled_Date__c, Payment_Cleared_Date__c, Payment_Status__c, Fee_Payment__C, Set_Payment__c, Processing_Fee__c
                    FROM Payment_History__c  WHERE Client__r.Id = :thePH];

       return payments;
    }
    
    public PageReference back()
    {      
        return new PageReference('/' + thePH);
    }
    
  // the Save button's method.  This will update both the parent and children records.
    public PageReference savePayments() {
        update payments;
        payments = getPayments();
        
        if (thePH == null)
        {
      return null;
        }
                
        Client__c phToUpdate = [ SELECT Id FROM Client__c WHERE Id = :thePH LIMIT 1];
        update phToUpdate;
        //return new PageReference('/' + thePH);
        
        // refresh current page
        return ApexPages.currentPage();
    }
}

 

 

Here is my attempt at adding the add row function, on this one the ad row function works..but the original function to display and save does not...lol what am i doing wrong????

 

 

public with sharing class BulkEdit {
    public List<Payment_History__c> payments {get; set;}
       public Id thePH;
 
        
  // class constructor 
    public BulkEdit() {
        thePH = ApexPages.currentPage().getParameters().get('id');
        payments = getPayments();
        payments = new List<Payment_History__c>();
        payments.add(new Payment_History__c());

    }
    public void addrow(){
        
        payments.add(new Payment_History__c());  
    }
    
  // get all the children for this Client__c
    public List<Payment_History__c> getPayments() {
      payments = [SELECT Name, Payment_Amount__c, Payment_Scheduled_Date__c, Payment_Cleared_Date__c, Payment_Status__c, Fee_Payment__C, Set_Payment__c, Processing_Fee__c
                    FROM Payment_History__c  WHERE Client__r.Id = :thePH];

       return payments;
    }

    public PageReference back()
    {      
        return new PageReference('/' + thePH);
    }
    
  // the Save button's method.  This will update both the parent and children records.
    public PageReference savePayments() {
        update payments;
        insert payments;
        payments = getPayments();
                             
        if (thePH == null)
        {
      return null;
        }
                
        Client__c phToUpdate = [ SELECT Id FROM Client__c WHERE Id = :thePH LIMIT 1];
        update phToUpdate;
        
        //return new PageReference('/' + thePH);
        
        // refresh current page
        return ApexPages.currentPage();
        
        
    }
    }

 

 

I have received a lot of help form these boards and greatly appreciate the opportunity to learn, my developer is on vaction until monday (shes been gone 2 weeks!) and I am trying to make sure we dont miss our deadline. Thank you for any help!

 

Jason Burns

I have a visual force page and apex class for editing multiple records at once, I am trying to make a button that creates a new record...I have the save function working, but cannot figure out how to create a new record. Any help would be appreciated!

 

Apex Class:

 

 

public with sharing class BulkEdit {
    public List<Payment_History__c> payments;
    public Id thePH;
    
  // class constructor 
    public BulkEdit() {
        thePH = ApexPages.currentPage().getParameters().get('id');
        payments = getPayments();
    }
    
  // get all the children for this Client__c
    public List<Payment_History__c> getPayments() {
      payments = [SELECT Name, Payment_Amount__c, Payment_Scheduled_Date__c, Payment_Cleared_Date__c, Payment_Status__c, Fee_Payment__C, Set_Payment__c, Processing_Fee__c
                    FROM Payment_History__c  WHERE Client__r.Id = :thePH];

       return payments;
    }
    
    public PageReference back()
    {      
        return new PageReference('/' + thePH);
    }
    
  // the Save button's method.  This will update both the parent and children records.
    public PageReference savePayments() {
        update payments;
        payments = getPayments();
        
        if (thePH == null)
        {
      return null;
        }
                
        Client__c phToUpdate = [ SELECT Id FROM Client__c WHERE Id = :thePH LIMIT 1];
        update phToUpdate;
        //return new PageReference('/' + thePH);
        
        // refresh current page
        return ApexPages.currentPage();
    }
}

 

 

VF Page:

 

 

<apex:page controller="BulkEdit" tabStyle="Client__c">

<apex:form id="theForm">
  <apex:pageBlock title="Payment Schedule" mode="edit">

<!-- our Save button tied to our Save method -->
            <apex:pageBlockButtons >
                <apex:commandButton action="{!savePayments}" value="Save"/>
                <apex:commandButton action="{!back}" value="Back to Client Record"/>
            </apex:pageBlockButtons>

<!--
     Here we create a table using the Visualforce tag <apex:pageBlockTable>
     {!payments} calls "getPayments" method in our controller.
     Note: the word "get" in accessor methods is implicit in Visualforce.
     We're also assigning a name variable of "currentPayment" for each accessed record.
     The IDs need to be present to perform the updates but we can keep them
     invisible to our user through rendered="false"
-->
            <apex:pageBlockTable value="{!payments}" var="currentPayment" id="theRepeat">
              <apex:outputText rendered="false">{!currentPayment.Client__r.Id}</apex:outputText>
              <apex:outputText rendered="false">{!currentPayment.Client__c}</apex:outputText>

<!--
     We create our columns, along with headers, for our user worksheet
     Depending on whether or not we want to allow the user to edit a field, we use
     the inputField or outputField tags.
-->
                <apex:column ><apex:facet name="header">Name</apex:facet>
                    <apex:outputField value="{!currentPayment.name}"/>
                </apex:column>
                <apex:column width="80px"><apex:facet name="header">Amount</apex:facet>
                    <apex:inputField value="{!currentPayment.Payment_Amount__c}" style="width:80px"/>
                </apex:column>
                <apex:column ><apex:facet name="header">Sched Date</apex:facet>
                    <apex:inputField value="{!currentPayment.Payment_Scheduled_Date__c}"/>
                </apex:column>
                <apex:column ><apex:facet name="header">Clear Date</apex:facet>
                    <apex:inputField value="{!currentPayment.Payment_Cleared_Date__c}"/>
                </apex:column>
                <apex:column ><apex:facet name="header">Status</apex:facet>
                     <apex:inputField value="{!currentPayment.Payment_Status__c}" style="{!IF((currentPayment.Payment_Status__c = 'Cleared'),'color:green','color:red')}"/>
                </apex:column>
                <apex:column ><apex:facet name="header">Processing Fee</apex:facet>
                    <apex:inputField value="{!currentPayment.Processing_Fee__c}"/>
                </apex:column>
                <apex:column ><apex:facet name="header">Retainer Fee</apex:facet>
                    <apex:inputField value="{!currentPayment.Fee_Payment__c}"/>
                </apex:column>
                <apex:column ><apex:facet name="header">Accumulation</apex:facet>
                    <apex:inputField value="{!currentPayment.Set_Payment__c}"/>
                </apex:column>
                
            </apex:pageBlockTable>
  </apex:pageBlock>
</apex:form>
              <apex:iframe id="xyz" src="/apex/Bulk_Edit_Offer_Payments?id={!$CurrentPage.parameters.Id}"></apex:iframe>

</apex:page>

 

 

 

 

 

Trying to upload this test class, but i am getting an error that apex test coverage is only 74%..which is why im trying to upload this test class lol..... any ideas? I am including the clas it is testing below....

 

 Appreciate any help!!

Thank You

 

@isTest
private class tableSortTest {
  private static void test() {
    Account a = new Account(name='Test');
    insert a;
    List<Task> tasks = new List<Task>{
      new Task(Subject='A Task',ActivityDate=System.Today(),Status='Completed',WhatId=a.id),
      new Task(Subject='Z Task',ActivityDate=System.Today().addDays(-1),Status='Not Started',WhatId=a.id)};
    insert tasks;
    Test.setCurrentPage(Page.Sort); 
    Test.startTest();
    ApexPages.currentPage().getParameters().put('id',a.id);
    tableSort controller = new tableSort();
    System.assertEquals(2,controller.getOpps().size());
    controller.sortField = 'Subject';
    controller.doSort();
    System.assertEquals('A Task',controller.getOpps()[0].Subject);
    controller.doSort();
    System.assertEquals('Z Task',controller.getOpps()[0].Subject);
    controller.sortField='ActivityDate';
    controller.doSort();
    System.assertEquals(System.Today().addDays(-1),controller.getOpps()[0].ActivityDate);
    controller.sortField='Subject';
    controller.doSort();
    System.assertEquals('A Task',controller.getOpps()[0].Subject);
    Test.stopTest();
  }
}

 

public class tableSort {

    public List<Task> opps;
    public Id theT;
    public String sortField {get; set;}
    public String previousSortField {get; set;}
    
      {
        theT = ApexPages.currentPage().getParameters().get('id');
        
    }
    
    public List<Task> getOpps() {
        if(opps == null){
            opps = [select WhatId, Subject, OwnerId, Description, ActivityDate from Task WHERE WhatId = :theT ];
        }
        return opps;
    }
    
    public void doSort(){
        String order = 'asc';
        
        /*This checks to see if the same header was click two times in a row, if so 
        it switches the order.*/
        if(previousSortField == sortField){
            order = 'desc';
            previousSortField = null;
        }else{
            previousSortField = sortField;
        }
       
        //To sort the table we simply need to use this one line, nice!
        superSort.sortList(opps,sortField,order);
    }
}

 

 

 

 

Trying to write test code for this apex class, can some one please help? I have another class to upload and my part-time developer is out of town! I am at 74% can some one PLEASE help me get it up a bit so I can upload my class?

 

 

public class tableSort {

    public List<Task> opps;
    public Id theT;
    public String sortField {get; set;}
    public String previousSortField {get; set;}
    
      {
        theT = ApexPages.currentPage().getParameters().get('id');
        
    }
    
    public List<Task> getOpps() {
        if(opps == null){
            opps = [select WhatId, Subject, OwnerId, Description, ActivityDate from Task WHERE WhatId = :theT ];
        }
        return opps;
    }
    
    public void doSort(){
        String order = 'asc';
        
        /*This checks to see if the same header was click two times in a row, if so 
        it switches the order.*/
        if(previousSortField == sortField){
            order = 'desc';
            previousSortField = null;
        }else{
            previousSortField = sortField;
        }
       
        //To sort the table we simply need to use this one line, nice!
        superSort.sortList(opps,sortField,order);
    }
}

 

 

Thanks in advance to anyone who might help!

 

JB