• Sneha Patil
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies

can anybody help me how can i cover this code...

 

public PageReference recedit() {
System.debug('*************************'+accid);
pagereference ref=new pagereference('/'+accid+'/e');
return ref;
}

 

 

and

 

public PageReference deleterec() {
Account acc=[select id,name from Account where id =: accid];
System.debug('***********************************'+acc);
delete acc;
pagereference ref=new pagereference('/apex/vieweditdelete');
ref.setredirect(true);
return ref;
}

 Is there eny way to improve my code in order to process about 30,000 records.

 

I would appreciate your help.

 

trigger SetPorcentajesdePerdidasEnCartera on RORAC__c (after insert) {

    
    for (RORAC__c rorac : System.Trigger.new) {
        
        for( Cartera_de_Credito__c cartera: [select id, Fecha_al__c, 
                                            Perdida_Esperada_p_Garant_a_Hipotec__c,
                                            Perdida_Esperada_p_Garant_a_Prendaria__c, 
                                            Perdida_Esperada_p_Garant_a_Hipotecaria__c
                                            from Cartera_de_Credito__c where Fecha_al__c =: rorac.Fecha_al__c ])
        {
                cartera.Perdida_Esperada_p_Garant_a_Hipotec__c = rorac.Perdida_Esperada_p_Garant_a_Hipotecaria__c;
                cartera.Perdida_Esperada_p_Garant_a_Prendaria__c = rorac.Perdida_Esperada_p_Garant_a_Prendaria__c ;
                cartera.Perdida_Esperada_p_Garant_a_Hipotecaria__c = rorac.Perdida_Esperada_p_Garant_a_Hipotecaria__c;
            
        update cartera;    
        }   
        
    } 
    }

 


HI all,


trigger DuplicateEmail on contact( before insert, before update) {
    Map<String, contact> contactMap = new Map<String, contact>();
      for (contact contact: System.Trigger.new) {
        if ((contact.Email!= null) &&
                  (System.Trigger.isInsert ||
                  (contact.Email!=
                      System.Trigger.oldMap.get(contact.Id).Email ))) {
      if (contactMap.containsKey(contact.Email )) {
                  contact.Email.addError('same email.');
              } else {
                  contactMap .put(contact.Email , contact);     
                           }
        }
      }
       for (contact contact: [SELECT Email  FROM contact WHERE Email IN :contactMap.KeySet()])
      {
          contact newcontact  = contactMap .get(contact.Email );
          newcontact.Email.addError('Email is already exhists with another contact ');
      }
  }

 

Not able to test Following lines...

 

My TEst Class:

@istest
public class testcontactemail
{
    public static testmethod void testemail()
    {
        account acc=new account();
        acc.name='test account';
        acc.Lead_Source__c='Website';
        insert acc;
        
        contact con=new contact();
        con.email='jabaraj.jaba@gmail.com';
        con.lastname='raj';
        con.accountid=acc.id;
        
        Exception e;
        
     /*   contact con1=new contact();
        con1.email='jabaraj.jaba@gmail.com';
        con1.lastname='raj';
        con1.accountid=acc.id;*/
        
        try
        {
            insert con;
        }
        catch(Exception ex)
        {
            e = ex;
          //  System.assert(e instanceOf System.DMLException);
        //    System.assert(e.getMessage().contains('FIELD_CUSTOM_VALIDATION_EXCEPTION'));
          System.assert(e.getMessage().contains('Record already exist with same email Id'));
          //  System.assert(false);
             
        }
      }

 

 

Thanks in Advance

  • September 28, 2013
  • Like
  • 0
<apex:page controller="controller">
<apex:form >
 <apex:pageBlock title="foo"> 
<apex:pageBlockButtons location="top">       
         <apex:commandButton id="DeleteBtn" value="{!$Label.Delete}" />
   </apex:pageBlockButtons> 
  <apex:pageBlockTable value="{!list}" var="list" title="foo">
      <apex:column >
        <input type="checkbox" value="{!list.id}" id = "checkbox"/> 
   </apex:column>
   <apex:column>
      <apex:facet name="header"> <apex:outputText value="Name" /> </apex:facet>
        <apex:outputField value="{!foo.Name__c}" />
    </apex:column>
  
    <apex:column > 
      <apex:facet name="header"> <apex:outputText value="Type" /> </apex:facet>
        <apex:outputField value="{!foo.Type__c}" />
    </apex:column>
    <apex:column > 
      <apex:facet name="header"> <apex:outputText value="Comments" /> </apex:facet>
      <apex:outputField value="{!foo.Comment__c}" />
    </apex:column>
    
  </apex:pageBlockTable> 
 </apex:pageBlock>
</apex:form>
</apex:page>

 CONTROLLER. 

 

I want to be able to delete multiple rows out of the table. So delete all checked rows with he delete button. How do I do this? 

public with sharing class controller {

public List<sObjects> myList 	{get; set;}
public String pId		{get; set;}							
	
    //CONSTRUCTOR
    public controller(){
    	 pId = ApexPages.CurrentPage().getparameters().get('id');
    	 myList = loadlist(); 
    }
    
    public list<People_Skill__c> loadList(){
    	List<sObjects> myList= [SELECT Id, name__c, type__c, comment__c,    FROM object__c WHERE id=:pId];
    	return mylist;
    }
}

 

  • September 25, 2013
  • Like
  • 0