• ram sf 10
  • NEWBIE
  • 0 Points
  • Member since 2015

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

I am New to Salesforce Development and strugling with the Code coverage for Apex Class which is used as an Extension in a Visualforce page.

This is my code for the Controller Class. Can Someone PLease help me out on this so that I can use this information as a guide for my future development.
*************************************************************************************************************
*************************************************************************************************************
public class manualpaymentcntrl{
  
    public Payment__c ptxn{ get; set; }
    public Contact con { get; set; }
    public Batch_Processing__c bp {get; set;}
    public Campaign c {get; set;}
    public boolean bsbnull {get; set;}
public manualpaymentcntrl(ApexPages.StandardController std) {
    con=new Contact();
    ptxn=new Payment__c();
    ptxn.Batch_Processing__c = ApexPages.currentPage().getParameters().get('Batch');
    ptxn.Campaign__c = ApexPages.currentPage().getParameters().get('Cam');
   }
 
public void obtaindetails() {
    for (Contact con : [select Name,FirstName,LastName,Email,AccountID,Phone,MobilePhone,Title, MailingStreet,MailingCity,MailingState,MailingCountry,MailingPostalCode,AAkPay_BSB_No__c,Account_No__c,Bank__c,Drawer__c from Contact where Id = :ptxn.Contact__c]){
  
        ptxn.FirstName__c = con.FirstName;
        ptxn.LastName__c = con.LastName;
        ptxn.Email__c = con.Email;
        ptxn.Account__c = con.AccountID;
        ptxn.Phone__c = con.Phone;
        ptxn.MobilePhone__c = con.MobilePhone;
        ptxn.Salutation__c = con.Title;
        ptxn.MailingStreet__c = con.MailingStreet;
        ptxn.MailingCity__c = con.MailingCity;
        ptxn.MailingState__c = con.MailingState;
        ptxn.MailingCountry__c = con.MailingCountry;
        ptxn.MailingPostalCode__c = con.MailingPostalCode;
        ptxn.BSB_No__c = con.AAkPay_BSB_No__c;
        ptxn.Account_No__c = con.Account_No__c;
                ptxn.Bank__c = con.Bank__c;
        ptxn.Drawer__c = con.Drawer__c;
                ptxn.Payment_Setting__c = 'a0m90000009Qwb4';
        ptxn.Payment_Type__c = 'a0o90000003Lhl2';
        ptxn.Bank_Deposit_Date__c = system.today();
        ptxn.Status__c = 'Receipting Start';
        ptxn.Transaction_Date__c = system.today();
        ptxn.Bank_Deposit_Account__c = '083-004-461061543' ;
        ptxn.Transaction_Type__c = 'Purchase';
   }
  }
    public void bankinfo(){
        if (ptxn.Method_of_Payment__c != 'Cheque'){
                ptxn.BSB_No__c = null;
            ptxn.Account_No__c = null;
                                ptxn.Bank__c = null;
                ptxn.Drawer__c = null;
           
        }
        else{
            ptxn.BSB_No__c = ptxn.Contact__r.AAkPay_BSB_No__c;
            ptxn.Account_No__c = ptxn.Contact__r.Account_No__c;
                ptxn.Bank__c = ptxn.Contact__r.Bank__c;
        ptxn.Drawer__c = ptxn.Contact__r.Drawer__c;
    }
    }
    public PageReference save(){
    String baseURL = URL.getSalesforceBaseUrl().toExternalForm();
    String PageURL = ApexPages.currentPage().getUrl();
    String wholeURL = baseURL+PageURL;
       
        for (Batch_Processing__c bp : [Select No_of_Transactions__c,Transaction_Count__c,Status__c from Batch_Processing__c where ID=:ptxn.Batch_Processing__c and Status__c != 'Completed']){
            insert ptxn;   
        PageReference reRend = new PageReference('/apex/custommanualpayment'+wholeURL);
        reRend.setRedirect(true);
        return reRend;
        }
        {
    PageReference reRend = new PageReference('/'+ptxn.Batch_Processing__c);
        reRend.setRedirect(true);
        return reRend;       
        }
    }
    public PageReference cancel(){
        PageReference reRend = new PageReference('/'+ptxn.Batch_Processing__c);
        reRend.setRedirect(true);
        return reRend;
    }
}

Thanks in Advance....

Regards,
Ram
Hi Everyone,

I am new to Salesforce Apex Coding and would greatly appreaciate if someone can help me out.

We have custom object called "Custom Payment" with a lookup field to Contact.
The following is my Apex Class that I am using as an Extension for a Visualforce Page to autopopulate the information from Contact Object when the Users Select a Contact on the Visualforce Page.

Everything is working fine and the record is also getting saved but than I recieve the Apex Governor Limit Warning emails from Salesforce.

Approaching limit for non-selective query against large object type (more than 100000 rows). Current size is approximately 90261 rows. When the limit is reached, the query will fail. Consider an indexed filter or contact salesforce.com about custom indexing.
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null) 2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times) null

*******************************************************************************************************************************
public class manualpaymentcntrl{
    public Custom_Payment__c ptxn { get; set; }
    public Contact con { get; set; }
        
public manualpaymentcntrl(ApexPages.StandardController std) {
    ptxn=new Custom_Payment__c ();//Create a new instance 
    con=new Contact();
}

public pagereference obtaindetails() {
   
       for ( Contact con : [select FirstName,LastName,Email,AccountID,Phone,MobilePhone,Title, MailingStreet,MailingCity,MailingState,MailingCountry,MailingPostalCode from Contact where Id = :ptxn.Contact__c]){
   
        ptxn.FirstName__c = con.FirstName;
        ptxn.LastName__c = con.LastName;
        ptxn.Email__c = con.Email;
        ptxn.Account__c = con.AccountID;
        ptxn.Phone__c = con.Phone;
        ptxn.MobilePhone__c = con.MobilePhone;
        ptxn.Salutation__c = con.Title;
        ptxn.MailingStreet__c = con.MailingStreet;
        ptxn.MailingCity__c = con.MailingCity;
        ptxn.MailingState__c = con.MailingState;
        ptxn.MailingCountry__c = con.MailingCountry;
        ptxn.MailingPostalCode__c = con.MailingPostalCode;
        
        ptxn.Payment_Setting__c = 'a0x900000012re5';
        ptxn.Frequency_Type__c = 'a0p9000000opqn1';
            
   
   }
    return null;
  }

    public PageReference save(){
       
        upsert ptxn;
      
        PageReference reRend = new PageReference('/apex/custommanualpayment');
        reRend.setRedirect(true);
        return reRend;
    }
    
    public PageReference cancel(){
       
            
        PageReference reRend = new PageReference('/apex/home/home.jsp');
        reRend.setRedirect(true);
        return reRend;
    }
}


Thanks In Advance......
Hi..

I am New to Salesforce Development and strugling with the Code coverage for Apex Class which is used as an Extension in a Visualforce page.

This is my code for the Controller Class. Can Someone PLease help me out on this so that I can use this information as a guide for my future development.
*************************************************************************************************************
*************************************************************************************************************
public class manualpaymentcntrl{
  
    public Payment__c ptxn{ get; set; }
    public Contact con { get; set; }
    public Batch_Processing__c bp {get; set;}
    public Campaign c {get; set;}
    public boolean bsbnull {get; set;}
public manualpaymentcntrl(ApexPages.StandardController std) {
    con=new Contact();
    ptxn=new Payment__c();
    ptxn.Batch_Processing__c = ApexPages.currentPage().getParameters().get('Batch');
    ptxn.Campaign__c = ApexPages.currentPage().getParameters().get('Cam');
   }
 
public void obtaindetails() {
    for (Contact con : [select Name,FirstName,LastName,Email,AccountID,Phone,MobilePhone,Title, MailingStreet,MailingCity,MailingState,MailingCountry,MailingPostalCode,AAkPay_BSB_No__c,Account_No__c,Bank__c,Drawer__c from Contact where Id = :ptxn.Contact__c]){
  
        ptxn.FirstName__c = con.FirstName;
        ptxn.LastName__c = con.LastName;
        ptxn.Email__c = con.Email;
        ptxn.Account__c = con.AccountID;
        ptxn.Phone__c = con.Phone;
        ptxn.MobilePhone__c = con.MobilePhone;
        ptxn.Salutation__c = con.Title;
        ptxn.MailingStreet__c = con.MailingStreet;
        ptxn.MailingCity__c = con.MailingCity;
        ptxn.MailingState__c = con.MailingState;
        ptxn.MailingCountry__c = con.MailingCountry;
        ptxn.MailingPostalCode__c = con.MailingPostalCode;
        ptxn.BSB_No__c = con.AAkPay_BSB_No__c;
        ptxn.Account_No__c = con.Account_No__c;
                ptxn.Bank__c = con.Bank__c;
        ptxn.Drawer__c = con.Drawer__c;
                ptxn.Payment_Setting__c = 'a0m90000009Qwb4';
        ptxn.Payment_Type__c = 'a0o90000003Lhl2';
        ptxn.Bank_Deposit_Date__c = system.today();
        ptxn.Status__c = 'Receipting Start';
        ptxn.Transaction_Date__c = system.today();
        ptxn.Bank_Deposit_Account__c = '083-004-461061543' ;
        ptxn.Transaction_Type__c = 'Purchase';
   }
  }
    public void bankinfo(){
        if (ptxn.Method_of_Payment__c != 'Cheque'){
                ptxn.BSB_No__c = null;
            ptxn.Account_No__c = null;
                                ptxn.Bank__c = null;
                ptxn.Drawer__c = null;
           
        }
        else{
            ptxn.BSB_No__c = ptxn.Contact__r.AAkPay_BSB_No__c;
            ptxn.Account_No__c = ptxn.Contact__r.Account_No__c;
                ptxn.Bank__c = ptxn.Contact__r.Bank__c;
        ptxn.Drawer__c = ptxn.Contact__r.Drawer__c;
    }
    }
    public PageReference save(){
    String baseURL = URL.getSalesforceBaseUrl().toExternalForm();
    String PageURL = ApexPages.currentPage().getUrl();
    String wholeURL = baseURL+PageURL;
       
        for (Batch_Processing__c bp : [Select No_of_Transactions__c,Transaction_Count__c,Status__c from Batch_Processing__c where ID=:ptxn.Batch_Processing__c and Status__c != 'Completed']){
            insert ptxn;   
        PageReference reRend = new PageReference('/apex/custommanualpayment'+wholeURL);
        reRend.setRedirect(true);
        return reRend;
        }
        {
    PageReference reRend = new PageReference('/'+ptxn.Batch_Processing__c);
        reRend.setRedirect(true);
        return reRend;       
        }
    }
    public PageReference cancel(){
        PageReference reRend = new PageReference('/'+ptxn.Batch_Processing__c);
        reRend.setRedirect(true);
        return reRend;
    }
}

Thanks in Advance....

Regards,
Ram