• Santhosh Parakunnath
  • NEWBIE
  • 10 Points
  • Member since 2014

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

We are seeing a difference in the number of lines of code shown in the developer console after running the test. The code has only 488 lines but the right hand panel shows that it has 675 lines and only 435 are covered. I have compiled the code and have waited for a couple of days to check if it is a temporary issue and nothing seems to change. This is in production.
User-added image
HI

I have a similar requirement as below..

https://developer.salesforce.com/page/Wrapper_Class

I also have to have a dropdown checkbox on the VF page to capture values from Picklist to insert into the new record. Everything seems to work fine in the below attached code except that when the records are inserted it inserts the same value for all the records it is inserting rather than getting the value for the inserting record from the picklist on the VF.

public OpportunityContactInsertController2 (){
        optyQueryString = 'SELECT FirstName,LastName,CreatedDate,AccountId from Contact where AccountId=:acId and Id not in (select Contact_Name__c from opportunity_Contact__c where Opportunity__c=:prId)';
        contList = new List<cContact>();
        optySetController = new ApexPages.Standardsetcontroller(Database.getQueryLocator(optyQueryString+' limit 10'));
        searchRecord = new Contact();
        helperRecord = new Reassign_Helper__c();
        isSuccess=false;
        searchPerformed = false;
        tooManyResults= false;
    }
    public void refreshContactListBySearch(){
        contList.clear();
        isSuccess = false;
        String userFilterQuery='';
        if (searchRecord.AccountId<>null)  userFilterQuery += ' and AccountId= \''+searchRecord.AccountId+'\'';             
        String optyQueryString =optyQueryString +  userFilterQuery ;
        optyQueryString += ' order by Name limit 2';
        
        List<Sobject> sortedResults= new List<SObject>();
        try{
            sortedResults = Database.query(optyQueryString);
            searchPerformed = true;
        } catch (Exception e){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
        }
        for (SObject foundObject:sortedResults){
            Contact opty = (Contact)foundObject;
            contList.add(new cContact(opty));      
        }
    }
    public void Assign(){     
        list<Opportunity_Contact__c> ContactInsertList=new list<Opportunity_Contact__c>();
        for (cContact opty:contList)
            if (opty.selected)
                ContactInsertList.add(new Opportunity_Contact__c(Contact_Name__c=opty.oContact.id, Opportunity__c=prId,Role__c='role', Loyalty__c=loyalty,Rank__c='1' ));
            try {
                Insert ContactInsertList;
            }
            catch (Exception e) {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
            } 
			
            integer n=contList.size();
            for (integer i=n-1;i>=0;i--){
                if (contList[i].selected) contList.remove(i);
            }  

            if (ContactInsertList.size()>0) isSuccess = true;
        } 
    public class cContact{
        public Contact oContact {get;set;}
        public Boolean selected {get;set;}
        public cContact(Contact oContact){
            this.oContact = oContact;
            selected=false;
            }

    }
    public list<SelectOption> getItems (){
         list<SelectOption> options = new list<SelectOption>();
         options.add(new SelectOption('','Select one'));
         options.add(new SelectOption('Entrenched Competitior','Entrenched Competitior'));
         options.add(new SelectOption('Switchable Competitior','Switchable Competitior'));
         return options;
     } 

        public string getSelectedItem(){
          return loyalty;
        }   

    	public void setSelectedItem(String loyalty){
         this.loyalty = loyalty;
     	}    
}


Hi

We are seeing a difference in the number of lines of code shown in the developer console after running the test. The code has only 488 lines but the right hand panel shows that it has 675 lines and only 435 are covered. I have compiled the code and have waited for a couple of days to check if it is a temporary issue and nothing seems to change. This is in production.
User-added image
HI

I have a similar requirement as below..

https://developer.salesforce.com/page/Wrapper_Class

I also have to have a dropdown checkbox on the VF page to capture values from Picklist to insert into the new record. Everything seems to work fine in the below attached code except that when the records are inserted it inserts the same value for all the records it is inserting rather than getting the value for the inserting record from the picklist on the VF.

public OpportunityContactInsertController2 (){
        optyQueryString = 'SELECT FirstName,LastName,CreatedDate,AccountId from Contact where AccountId=:acId and Id not in (select Contact_Name__c from opportunity_Contact__c where Opportunity__c=:prId)';
        contList = new List<cContact>();
        optySetController = new ApexPages.Standardsetcontroller(Database.getQueryLocator(optyQueryString+' limit 10'));
        searchRecord = new Contact();
        helperRecord = new Reassign_Helper__c();
        isSuccess=false;
        searchPerformed = false;
        tooManyResults= false;
    }
    public void refreshContactListBySearch(){
        contList.clear();
        isSuccess = false;
        String userFilterQuery='';
        if (searchRecord.AccountId<>null)  userFilterQuery += ' and AccountId= \''+searchRecord.AccountId+'\'';             
        String optyQueryString =optyQueryString +  userFilterQuery ;
        optyQueryString += ' order by Name limit 2';
        
        List<Sobject> sortedResults= new List<SObject>();
        try{
            sortedResults = Database.query(optyQueryString);
            searchPerformed = true;
        } catch (Exception e){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
        }
        for (SObject foundObject:sortedResults){
            Contact opty = (Contact)foundObject;
            contList.add(new cContact(opty));      
        }
    }
    public void Assign(){     
        list<Opportunity_Contact__c> ContactInsertList=new list<Opportunity_Contact__c>();
        for (cContact opty:contList)
            if (opty.selected)
                ContactInsertList.add(new Opportunity_Contact__c(Contact_Name__c=opty.oContact.id, Opportunity__c=prId,Role__c='role', Loyalty__c=loyalty,Rank__c='1' ));
            try {
                Insert ContactInsertList;
            }
            catch (Exception e) {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
            } 
			
            integer n=contList.size();
            for (integer i=n-1;i>=0;i--){
                if (contList[i].selected) contList.remove(i);
            }  

            if (ContactInsertList.size()>0) isSuccess = true;
        } 
    public class cContact{
        public Contact oContact {get;set;}
        public Boolean selected {get;set;}
        public cContact(Contact oContact){
            this.oContact = oContact;
            selected=false;
            }

    }
    public list<SelectOption> getItems (){
         list<SelectOption> options = new list<SelectOption>();
         options.add(new SelectOption('','Select one'));
         options.add(new SelectOption('Entrenched Competitior','Entrenched Competitior'));
         options.add(new SelectOption('Switchable Competitior','Switchable Competitior'));
         return options;
     } 

        public string getSelectedItem(){
          return loyalty;
        }   

    	public void setSelectedItem(String loyalty){
         this.loyalty = loyalty;
     	}    
}