• csrsak
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 8
    Replies
Hi All,

I have a requirement in one of custom application, requirement is like,

Applications having two custom objects like A and B, both objects have some same sections.

In custom object ‘A’ having one field of data type picklist like name is ownership, values of picklist is like own, other, joint under one section.

When the ownership = ‘joint’, what ever the values are filled in the fields of ‘A’ object under the particular section, after the save is happen in ‘A’ object,

Same values of that section are update in ‘B’ custom object of the same section.

Please help me to write the code of this scenario. or any suggestions for this.

Thanks in Advance,


Thanks and Regards,

Srinivas Chittela
  • October 27, 2009
  • Like
  • 0

Hi,

 

I have a requirement in my application, requirement is like,

 

In one of the section of an object (example like 'LOAN' section), having two fields like A and B.

 

If a user enter some value into 'A' field, then the user must enter the value in 'B',

 

And if user enter value in 'B' field, then he must enter the value in 'A' field.

 

If the user not enter any data then the both fields should be empty.

 

 

Please help me, how to write the code to meet this requirement? Or can you please tell me any suggestion to fulfill this requirement?

 

Thanks in Advance,

 

 

Thanks and Regards,

 

Srinivas Chittela

 

 

 

 

  • October 16, 2009
  • Like
  • 0

Hi,

 

I wrote test class for apex class, when i run that test class it shows '0' lines not tested, 100% covered.

 

Apex class is:

 

public with sharing class CustomerRetirement
{

public CustomerRetirement(ApexPages.StandardController controller)
    {
      this.retirement= (Customer_Retirement_Detail__c)controller.getRecord();
      updateRetirementDetails = getCustomerRetirement();
    }
      public CustomerRetirement(){}
      List<Customer_Retirement_Detail__c> customerRetirementDetails;
      private final List<Customer_Retirement_Detail__c> updateRetirementDetails;
     
      private String educationGoalId;
      private String customerId;
      private String message=null;
              
    public String getCustomerId()
    {
      return customerId;
    }
   
    public void setCustomerId(String customerId)
    {
      this.customerId=customerId;
    }        
  
   public boolean isCustomerIdExit()
      {
        boolean isCustomerId=false;
        List<Customer_Retirement_Detail__c> duplicateRetirementId=[select Customer_Id__c
      from Customer_Retirement_Detail__c where Customer_ID__c = :retirement.Customer_Id__c];
      for(Customer_Retirement_Detail__c retirement1:duplicateRetirementId)
      if(retirement1.Customer_Id__c == retirement.Customer_Id__c)
      {
       isCustomerId=true;
      }
      else
      {
       isCustomerId=false;
      }
     return isCustomerId;
      }
  
        
   public PageReference cancelRecord()
 {
   PageReference page=null;
      page = new PageReference('/apex/LifeInsuranceTab');
      return page;
 }
 
   public PageReference save()
   {
     Integer p = 0;
     ApexPages.Message myMsg=null;
     try
     {
      String insuredPartyId=null;
      boolean isCustomerId = isCustomerIdExit();
      List<CustomerFinancialDetail__c> insuranceId =[select id from CustomerFinancialDetail__c
      where Customer_Id__c =: retirement.Customer_Id__c];
      for(CustomerFinancialDetail__c cfd : insuranceId)
      {
       insuredPartyId = cfd.id;
       system.debug('******** Insured Party Id **********'+insuredPartyId);
      }
      if(isCustomerId == true)
      {
       message='Customer ID already in use';
       myMsg = new ApexPages.Message(ApexPages.severity.ERROR,'Customer ID already in use','');
       ApexPages.addMessage(myMsg);
      }
      else
      {
      retirement.Customer_Id__c=retirement.Customer_Id__c;
      retirement.Financial_Detail__c = insuredPartyId;
      retirement.Currency__c = retirement.Currency__c;
      retirement.Annual_rate_at_retire_income_should_incr__c=retirement.Annual_rate_at_retire_income_should_incr__c;
      retirement.Customer_s_retirement_year__c=retirement.Customer_s_retirement_year__c;
      retirement.Max_Age__c=retirement.Max_Age__c;
      retirement.Retire_income_payable_until_Age_year__c=retirement.Retire_income_payable_until_Age_year__c;
      retirement.Retire_income_wanted_at_retirement_date__c=retirement.Retire_income_wanted_at_retirement_date__c;
      retirement.Future_rate_of_Annual_price_inflation__c=retirement.Future_rate_of_Annual_price_inflation__c;
      retirement.Desired_monthly_income_at_retirement__c=retirement.Desired_monthly_income_at_retirement__c;
      retirement.Avg_rate_of_retire_income_for_Funded__c=retirement.Avg_rate_of_retire_income_for_Funded__c;
      retirement.Purch_powertoday_s_desiredmonthly_income__c=retirement.Purch_powertoday_s_desiredmonthly_income__c;
      retirement.Future_annualrate_ofreturn_oninvestments__c=retirement.Future_annualrate_ofreturn_oninvestments__c;
      retirement.Age_at_which_the_plan_benefit_begins__c=retirement.Age_at_which_the_plan_benefit_begins__c;
      retirement.Estimated_Plan_income_at_retirement__c=retirement.Estimated_Plan_income_at_retirement__c;
      retirement.No_of_years_the_plan_benefit_is_paid__c=retirement.No_of_years_the_plan_benefit_is_paid__c;
      retirement.A_R_O_rtrmt_income_incr_frm_these_plans__c=retirement.A_R_O_rtrmt_income_incr_frm_these_plans__c;
      retirement.Plan_Beginning_Year__c=retirement.Plan_Beginning_Year__c;
      retirement.Plan_Maturity_Year__c=retirement.Plan_Maturity_Year__c;
      retirement.Plan_Current_Value__c=retirement.Plan_Current_Value__c;
      retirement.Plan_Maturity_Value__c=retirement.Plan_Maturity_Value__c;
      retirement.Rate_of_Increase_in_Plan_Value__c=retirement.Rate_of_Increase_in_Plan_Value__c;
      retirement.Age_at_which_plan_benefit_begins__c=retirement.Age_at_which_plan_benefit_begins__c;
      retirement.Plan_Annual_Contribution__c=retirement.Plan_Annual_Contribution__c;
      retirement.Rate_of_incr_in_contributions_this_plan__c=retirement.Rate_of_incr_in_contributions_this_plan__c;
      retirement.Estd_plan_annual_income_at_retirement__c=retirement.Estd_plan_annual_income_at_retirement__c;
      retirement.No_of_years_plan_benefit_is_paid__c=retirement.No_of_years_plan_benefit_is_paid__c;
      retirement.R_O_incm_rtrmt_plan_assumed_to_produce__c=retirement.R_O_incm_rtrmt_plan_assumed_to_produce__c;
      retirement.Estd_plan_annual_incm_frm_G_p_s_at_rtrmt__c=retirement.Estd_plan_annual_incm_frm_G_p_s_at_rtrmt__c;
      retirement.A_R_of_increase_in_income_for_govt__c=retirement.A_R_of_increase_in_income_for_govt__c;
      retirement.E_P_Othr_income_frm_all_sources_at_rtrmt__c=retirement.E_P_Othr_income_frm_all_sources_at_rtrmt__c;
      retirement.A_R_of_increase_in_income_for_other__c=retirement.A_R_of_increase_in_income_for_other__c;
      retirement.Future_A_R_of_return_on_investment__c=retirement.Future_A_R_of_return_on_investment__c;
      retirement.Plan_anual_income_frm_s_s_bnfts_at_rtrmt__c=retirement.Plan_anual_income_frm_s_s_bnfts_at_rtrmt__c;
      retirement.Rate_of_increase_in_s_s_s_benefits__c=retirement.Rate_of_increase_in_s_s_s_benefits__c;
      insert retirement;
      p=2;
      }
        }
      catch(Exception e)
      {
         p=1;
         ApexPages.addMessages(e);
      }
      if(p==2)
      {
       message='Record Inserted Sucessfully';
       myMsg = new ApexPages.Message(ApexPages.severity.CONFIRM,'Record Inserted Sucessfully','');
       ApexPages.addMessage(myMsg);
      }
      return null;
     }
    
     public PageReference updateRecord()
    {
       
        ApexPages.Message myMsg=null;
        try
      {
        Database.SaveResult[] sr = Database.update(updateRetirementDetails);
        for(Database.SaveResult sr1 : sr)
        if(sr1.isSuccess())
        {
          myMsg = new ApexPages.Message(ApexPages.severity.CONFIRM,'Record Saved Sucessfully','');
          ApexPages.addMessage(myMsg);
        } 
      }
     catch(DmlException ex)
     {
       ApexPages.addMessages(ex);
     }
      return null;
    }
    
   public List<Customer_Retirement_Detail__c> getUpdateRetirementDetails()
   {
       return updateRetirementDetails;
   }
  
      public List<Customer_Retirement_Detail__c> getCustomerRetirement()
    {
        this.customerId = ApexPages.currentPage().getParameters().get('customerId');
        customerRetirementDetails=[select Financial_Detail__c,
        Customer_Id__c,Customer_Id__r.Name,Currency__c,Annual_rate_at_retire_income_should_incr__c,
     Customer_s_retirement_year__c,Max_Age__c,Retire_income_payable_until_Age_year__c,
     Retire_income_wanted_at_retirement_date__c,Future_rate_of_Annual_price_inflation__c,
     Desired_monthly_income_at_retirement__c,Avg_rate_of_retire_income_for_Funded__c,
     Purch_powertoday_s_desiredmonthly_income__c,Future_annualrate_ofreturn_oninvestments__c,
     Age_at_which_the_plan_benefit_begins__c,Estimated_Plan_income_at_retirement__c,
     No_of_years_the_plan_benefit_is_paid__c,A_R_O_rtrmt_income_incr_frm_these_plans__c,
     Plan_Beginning_Year__c,Plan_Maturity_Year__c,
     Plan_Current_Value__c,Plan_Maturity_Value__c,
     Rate_of_Increase_in_Plan_Value__c,Age_at_which_plan_benefit_begins__c,Plan_Annual_Contribution__c,
     Rate_of_incr_in_contributions_this_plan__c,Estd_plan_annual_income_at_retirement__c,
     No_of_years_plan_benefit_is_paid__c,R_O_incm_rtrmt_plan_assumed_to_produce__c,
     Estd_plan_annual_incm_frm_G_p_s_at_rtrmt__c,A_R_of_increase_in_income_for_govt__c,
     E_P_Othr_income_frm_all_sources_at_rtrmt__c,A_R_of_increase_in_income_for_other__c,
     Future_A_R_of_return_on_investment__c,Plan_anual_income_frm_s_s_bnfts_at_rtrmt__c,
     Rate_of_increase_in_s_s_s_benefits__c,Defined_Benefit_or_Final_Salary_Plan__c,
     Funded_Retirement_Plan__c,Government_Pension_Scheme__c,Income_from_assets__c,
     Other_Income_During_Retirements__c,Social_Security_Benefits__c
     from Customer_Retirement_Detail__c where Customer_ID__c = :customerId];
        return customerRetirementDetails;
    }
    private final Customer_Retirement_Detail__c retirement;
}

 

 

I wrote test class is like this,

 

@isTest
private class CustomerRetirementTest
{

    static testMethod void myUnitTest()
     {
     }
   
    public static testmethod void testIsCustomerIdExit()
    {
     String duplicateRetirementId1='a0680000005zYu8';
     List<Customer_Retirement_Detail__c> duplicateRetirementId=[select Customer_Id__c
     from Customer_Retirement_Detail__c where Customer_ID__c = :duplicateRetirementId1];
     for(Customer_Retirement_Detail__c retirement1:duplicateRetirementId)
     system.assertEquals(retirement1.Customer_Id__c,duplicateRetirementId1);
    }
   
    public static testmethod void testCancelRecord()
   {
    String page='/apex/LifeInsuranceTab';
    system.assertEquals(page,'/apex/LifeInsuranceTab');
   }
   public static testmethod void testSave()
   {
    Customer_Retirement_Detail__c crd=new Customer_Retirement_Detail__c();
    crd.Customer_Id__c='a0680000005zYu8';
    crd.Currency__c='$';
    crd.Annual_rate_at_retire_income_should_incr__c=5;
    crd.Customer_s_retirement_year__c=Date.newInstance(2035,09,02);
    crd.Max_Age__c=60;
    crd.Retire_income_payable_until_Age_year__c=60;
    crd.Retire_income_wanted_at_retirement_date__c=1200000;
    crd.Future_rate_of_Annual_price_inflation__c=15;
    crd.Desired_monthly_income_at_retirement__c=25000;
    crd.Avg_rate_of_retire_income_for_Funded__c=20;
    crd.Purch_powertoday_s_desiredmonthly_income__c=15000;
    crd.Future_annualrate_ofreturn_oninvestments__c=14;
    crd.Age_at_which_the_plan_benefit_begins__c=26;
    crd.Estimated_Plan_income_at_retirement__c=600000;
    crd.No_of_years_the_plan_benefit_is_paid__c=24;
    crd.A_R_O_rtrmt_income_incr_frm_these_plans__c=12;
    crd.Plan_Beginning_Year__c='2004';
    crd.Plan_Maturity_Year__c='2035';
    crd.Plan_Current_Value__c=150000;
    crd.Plan_Maturity_Value__c=750000;
    crd.Rate_of_Increase_in_Plan_Value__c=18;
    crd.Age_at_which_plan_benefit_begins__c=28;
    crd.Plan_Annual_Contribution__c=45000;
    crd.Rate_of_incr_in_contributions_this_plan__c=13;
    crd.Estd_plan_annual_income_at_retirement__c=600000;
    crd.No_of_years_plan_benefit_is_paid__c=14;
    crd.R_O_incm_rtrmt_plan_assumed_to_produce__c=17;
    crd.Estd_plan_annual_incm_frm_G_p_s_at_rtrmt__c=450000;
    crd.A_R_of_increase_in_income_for_govt__c=14;
    crd.E_P_Othr_income_frm_all_sources_at_rtrmt__c=170000;
    crd.A_R_of_increase_in_income_for_other__c=15;
    crd.Future_A_R_of_return_on_investment__c=13;
    crd.Plan_anual_income_frm_s_s_bnfts_at_rtrmt__c=450000;
    crd.Rate_of_increase_in_s_s_s_benefits__c=16;
   }
}

 

Can any one help me, excpected code for line coverage and code coverage of 75%?

 

Thanks in Advance,

 

 

Thanks and Regards,

 

Srinivas Chittela

  • October 13, 2009
  • Like
  • 0

Hi Folks,

 

Please help me to write Test class for Trigger Class below.

 

 

trigger TriggerAfterLeadConversion on Lead (after update)

{

 for(Lead lead:Trigger.new)

 {

 if (Lead.IsConverted)

{

 

 Contact con = [SELECT Id FROM Contact WHERE Contact.Id = :lead.ConvertedContactId]; con.Birthdate = lead.Date_Of_Birth__c; con.Email=lead.Email; update con;

}

 }

 }

 

Thanks in advance

 

Thanks & Regards

Srinivas

  • October 12, 2009
  • Like
  • 0

Hi Friends,
 
I have a requirement for doing the calculation in formula field,

 

when I save the calculation of a formula field,

 

it is showing the,

 

Compiled formula is too big to execute (6,395 characters). Maximum size is 5,000 characters.

 

formula is looking like this,


[CV* ( 1+IPV/100)**( NM/12)] +[ Sum from Y= 1to Y=NY of { AC* [( 1+ INCC/100)**( NY-Y+1)] *[ (1+IPV/100)**Y]},

as our requirement i did this formula is like this,

Financial_Detail__r.Plan_current_value__c * ( ( Financial_Detail__r.Rate_of_Increase_in_Plan_Value__c ) ^ ( CEILING( Complete_month_bwn_maturity_year_today__c / 12) ) )
+
( Complete_years_bwn_Maturity_yr_today__c )
*
(( Plan_Annual_Contribution__c )
*
(( ((1+ Rate_of_incr_in_contributions_this_plan__c ) ^CEILING ( Complete_years_bwn_Maturity_yr_today__c-( YEAR( TODAY() ) - YEAR( Financial_Detail__r.Plan_beginning_year__c ) )+1 ))
*
((1+ Financial_Detail__r.Rate_of_Increase_in_Plan_Value__c )^CEILING(YEAR( TODAY() ) - YEAR( Financial_Detail__r.Plan_beginning_year__c ))))))


 
I Spilt this formula in two formula fields and i call those two formula fields in actuval formula field. and when i save this formula, it showing compiled size too big to execute.

Can any one please tell me,how to resolve this problem?

 

Thanks in Advance,


Thanks and Regards,

Srinivas Chittela

 

  • September 11, 2009
  • Like
  • 0

Hi Friends,

 

I have a requirement for doing the calculation in formula field,

 

when I save the calculation of a formula field,

 

it is showing the,

 

Compiled formula is too big to execute (6,395 characters). Maximum size is 5,000 characters.

 

formula is looking like this,

[CV* ( 1+IPV/100)**( NM/12)] +[ Sum from Y= 1to Y=NY of { AC* [( 1+ INCC/100)**( NY-Y+1)] *[ (1+IPV/100)**Y]},

as our requirement i did this formula is like this,

Financial_Detail__r.Plan_current_value__c * ( ( Financial_Detail__r.Rate_of_Increase_in_Plan_Value__c ) ^ ( CEILING( Complete_month_bwn_maturity_year_today__c / 12) ) )

+

( Complete_years_bwn_Maturity_yr_today__c )
*
(( Plan_Annual_Contribution__c )
*
(( ((1+ Rate_of_incr_in_contributions_this_plan__c ) ^CEILING ( Complete_years_bwn_Maturity_yr_today__c-( YEAR( TODAY() ) - YEAR( Financial_Detail__r.Plan_beginning_year__c ) )+1 ))

*

((1+ Financial_Detail__r.Rate_of_Increase_in_Plan_Value__c )^CEILING(YEAR( TODAY() ) - YEAR( Financial_Detail__r.Plan_beginning_year__c ))))))

 

 

Can any one please tell me,how to resolve this problem?

 

Thanks in Advance,

 

Thanks and Regards,

Srinivas Chittela

Message Edited by csrsak on 09-10-2009 02:40 AM
  • September 10, 2009
  • Like
  • 0

Hi Friends,

 

I am new into this salesforce.com platform, as of my requirement I did the test class,

 

When I run the test class, it shows 35% of test coverage,

 

Please help me to resolve the remaining.

 

Trigger is:

 

trigger TriggerAfterLeadConversion on Lead (after update)
{
 for(Lead lead:Trigger.new)
 {
  if (Lead.IsConverted)
     {
      
Contact con = [SELECT Id FROM Contact WHERE Contact.Id = :lead.ConvertedContactId];           
       con.Birthdate = lead.Date_Of_Birth__c;
       con.Email=lead.Email;           
       update con;
    
      }
  }
}

 

Trigger test class is,

 

@isTest

private class TriggerAfterLeadConversionTest
{

    static testMethod void myUnitTest()
    {
    Lead le=new Lead(Date_of_Birth__c=Date.newInstance(1984,10,11),
Email='svreddych@gmail.com', Company='Saksoft',LastName='reddy');
 insert le;
 
 Contact con = new Contact(firstName='srinivas',lastName='reddy',Email='svreddych@gmail.com');
 insert con;
 con.Birthdate=le.Date_of_Birth__c;
 con.Email=le.Email;
 update con;
 update le;
 system.assertEquals('Email',le.Email);
 
    }
}

 

When I run tests for test trigger class it shows,

 

The red color code in trigger are not covered,

 

Please help me to resolve this,

 

Thanks in advance,

 

Regards,

Srinivas Chittela

  • August 28, 2009
  • Like
  • 0

Hi Folks, 

 

I wrote the trigger test class for trigger, and when I run tests for the trigger test class; 

 

It shows the exception like,

 

System.QueryException:List has no rows for assignment to SObject, 

 

Trigger is,

 

trigger TriggerAfterLeadConversion on Lead (after update)
{
 for(Lead lead:Trigger.new)
 {
  if (Lead.IsConverted)
     {
       Contact con = [SELECT Id FROM Contact WHERE Contact.Id = :lead.ConvertedContactId];           
       con.Birthdate = lead.Date_Of_Birth__c;
       con.Email=lead.Email;           
       update con;    
      }
  }
}

 

 

Trigger Test class is, 

 

 

@isTest

private class TriggerAfterLeadConversionTest
{
   static testMethod void myUnitTest()
    {
    Lead le=new Lead(Date_of_Birth__c=Date.newInstance(1984,10,11),
Email='svreddych@gmail.com', Company='Saksoft',LastName='reddy');
 insert le;
 Contact con = [SELECT Id FROM Contact WHERE Contact.Id = '00Q8000000SyVy2EAF'];
 insert con;
 con.Birthdate=le.Date_of_Birth__c;
 con.Email=le.Email;
 update con;
 system.assertEquals('Email',le.Email);
    }
}

 

 

(if i wrote the trigger test class like this, in place of red color in above code, 

 

Contact con = new Contact(Id=le.ID),

 

it shows error like,

 

System.TypeException:Invalid id value for this SObject type: 008000000TCVXmEAp)

 

Please help me to resolve this issue... 

 

Thanks in Advance,

 

Regards, 

 

Srinivas Chittela

 

Message Edited by csrsak on 08-27-2009 05:49 AM
Message Edited by csrsak on 08-27-2009 05:50 AM
Message Edited by csrsak on 08-27-2009 05:51 AM
  • August 27, 2009
  • Like
  • 0
Hi Folks,  I am new into Salesforce.com; I need to write a test class for trigger, i wrote test class for the following trigger and when i run the test class,  It is showing 0% coverage and the following red color lines are not covered,  Trigger is: trigger insertIntoCustomerContactDetail on Contact (after update)
{
 
for (Contact a : Trigger.new)
     {
       
CustomerContactDetail__c ccd = new CustomerContactDetail__c
        (
           Contact__c = a.id,
           First_Name__c =a.firstName,
           Last_Name__c=a.lastName,
           Date_Of_Birth__c = a.Birthdate,
           Mobile_No__c = a.MobilePhone,
           Email__c = a.Email
         );
         insert ccd ;
      }
 }

 

Test class:

 

@isTestprivate class insertIntoCustomerContactDetailTest {     static testMethod void myUnitTest()     {        Contact a=new Contact();                        //a.id='a018000000McFcK';                        a.firstName='srinu';                        a.lastName='reddy';                        a.Birthdate=Date.newInstance(1984,10,11);                        a.MobilePhone='9711099217';                        a.Email='svreddych@gmail.com';                        try                        {                        update a;                                             CustomerContactDetail__c ccd=new CustomerContactDetail__c                        (                        Contact__c=a.id,                        First_Name__c=a.firstName,                        Last_Name__c=a.lastName,                        Date_Of_Birth__c=a.Birthdate,                        Mobile_No__c=a.MobilePhone,                        Email__c=a.Email                        );                        insert ccd;                        }                                                catch(system.DmlException e)                        {                                    System.debug('we caught a dml exception: ' + e.getDmlMessage(0));                            }    }

}

 

please help me, in this regards.... in correct way.

 

Thanks in Advance, 

 

Srinivas Chittela

  • August 27, 2009
  • Like
  • 0

Hi Folks,

 

Please help me to write Test class for Trigger Class below.

 

 

trigger TriggerAfterLeadConversion on Lead (after update)

{

 for(Lead lead:Trigger.new)

 {

 if (Lead.IsConverted)

{

 

 Contact con = [SELECT Id FROM Contact WHERE Contact.Id = :lead.ConvertedContactId]; con.Birthdate = lead.Date_Of_Birth__c; con.Email=lead.Email; update con;

}

 }

 }

 

Thanks in advance

 

Thanks & Regards

Srinivas

  • October 12, 2009
  • Like
  • 0

Hi Friends,

 

I have a requirement for doing the calculation in formula field,

 

when I save the calculation of a formula field,

 

it is showing the,

 

Compiled formula is too big to execute (6,395 characters). Maximum size is 5,000 characters.

 

formula is looking like this,

[CV* ( 1+IPV/100)**( NM/12)] +[ Sum from Y= 1to Y=NY of { AC* [( 1+ INCC/100)**( NY-Y+1)] *[ (1+IPV/100)**Y]},

as our requirement i did this formula is like this,

Financial_Detail__r.Plan_current_value__c * ( ( Financial_Detail__r.Rate_of_Increase_in_Plan_Value__c ) ^ ( CEILING( Complete_month_bwn_maturity_year_today__c / 12) ) )

+

( Complete_years_bwn_Maturity_yr_today__c )
*
(( Plan_Annual_Contribution__c )
*
(( ((1+ Rate_of_incr_in_contributions_this_plan__c ) ^CEILING ( Complete_years_bwn_Maturity_yr_today__c-( YEAR( TODAY() ) - YEAR( Financial_Detail__r.Plan_beginning_year__c ) )+1 ))

*

((1+ Financial_Detail__r.Rate_of_Increase_in_Plan_Value__c )^CEILING(YEAR( TODAY() ) - YEAR( Financial_Detail__r.Plan_beginning_year__c ))))))

 

 

Can any one please tell me,how to resolve this problem?

 

Thanks in Advance,

 

Thanks and Regards,

Srinivas Chittela

Message Edited by csrsak on 09-10-2009 02:40 AM
  • September 10, 2009
  • Like
  • 0

Hi Friends,

 

I am new into this salesforce.com platform, as of my requirement I did the test class,

 

When I run the test class, it shows 35% of test coverage,

 

Please help me to resolve the remaining.

 

Trigger is:

 

trigger TriggerAfterLeadConversion on Lead (after update)
{
 for(Lead lead:Trigger.new)
 {
  if (Lead.IsConverted)
     {
      
Contact con = [SELECT Id FROM Contact WHERE Contact.Id = :lead.ConvertedContactId];           
       con.Birthdate = lead.Date_Of_Birth__c;
       con.Email=lead.Email;           
       update con;
    
      }
  }
}

 

Trigger test class is,

 

@isTest

private class TriggerAfterLeadConversionTest
{

    static testMethod void myUnitTest()
    {
    Lead le=new Lead(Date_of_Birth__c=Date.newInstance(1984,10,11),
Email='svreddych@gmail.com', Company='Saksoft',LastName='reddy');
 insert le;
 
 Contact con = new Contact(firstName='srinivas',lastName='reddy',Email='svreddych@gmail.com');
 insert con;
 con.Birthdate=le.Date_of_Birth__c;
 con.Email=le.Email;
 update con;
 update le;
 system.assertEquals('Email',le.Email);
 
    }
}

 

When I run tests for test trigger class it shows,

 

The red color code in trigger are not covered,

 

Please help me to resolve this,

 

Thanks in advance,

 

Regards,

Srinivas Chittela

  • August 28, 2009
  • Like
  • 0

Hi Folks, 

 

I wrote the trigger test class for trigger, and when I run tests for the trigger test class; 

 

It shows the exception like,

 

System.QueryException:List has no rows for assignment to SObject, 

 

Trigger is,

 

trigger TriggerAfterLeadConversion on Lead (after update)
{
 for(Lead lead:Trigger.new)
 {
  if (Lead.IsConverted)
     {
       Contact con = [SELECT Id FROM Contact WHERE Contact.Id = :lead.ConvertedContactId];           
       con.Birthdate = lead.Date_Of_Birth__c;
       con.Email=lead.Email;           
       update con;    
      }
  }
}

 

 

Trigger Test class is, 

 

 

@isTest

private class TriggerAfterLeadConversionTest
{
   static testMethod void myUnitTest()
    {
    Lead le=new Lead(Date_of_Birth__c=Date.newInstance(1984,10,11),
Email='svreddych@gmail.com', Company='Saksoft',LastName='reddy');
 insert le;
 Contact con = [SELECT Id FROM Contact WHERE Contact.Id = '00Q8000000SyVy2EAF'];
 insert con;
 con.Birthdate=le.Date_of_Birth__c;
 con.Email=le.Email;
 update con;
 system.assertEquals('Email',le.Email);
    }
}

 

 

(if i wrote the trigger test class like this, in place of red color in above code, 

 

Contact con = new Contact(Id=le.ID),

 

it shows error like,

 

System.TypeException:Invalid id value for this SObject type: 008000000TCVXmEAp)

 

Please help me to resolve this issue... 

 

Thanks in Advance,

 

Regards, 

 

Srinivas Chittela

 

Message Edited by csrsak on 08-27-2009 05:49 AM
Message Edited by csrsak on 08-27-2009 05:50 AM
Message Edited by csrsak on 08-27-2009 05:51 AM
  • August 27, 2009
  • Like
  • 0
Hi Folks,  I am new into Salesforce.com; I need to write a test class for trigger, i wrote test class for the following trigger and when i run the test class,  It is showing 0% coverage and the following red color lines are not covered,  Trigger is: trigger insertIntoCustomerContactDetail on Contact (after update)
{
 
for (Contact a : Trigger.new)
     {
       
CustomerContactDetail__c ccd = new CustomerContactDetail__c
        (
           Contact__c = a.id,
           First_Name__c =a.firstName,
           Last_Name__c=a.lastName,
           Date_Of_Birth__c = a.Birthdate,
           Mobile_No__c = a.MobilePhone,
           Email__c = a.Email
         );
         insert ccd ;
      }
 }

 

Test class:

 

@isTestprivate class insertIntoCustomerContactDetailTest {     static testMethod void myUnitTest()     {        Contact a=new Contact();                        //a.id='a018000000McFcK';                        a.firstName='srinu';                        a.lastName='reddy';                        a.Birthdate=Date.newInstance(1984,10,11);                        a.MobilePhone='9711099217';                        a.Email='svreddych@gmail.com';                        try                        {                        update a;                                             CustomerContactDetail__c ccd=new CustomerContactDetail__c                        (                        Contact__c=a.id,                        First_Name__c=a.firstName,                        Last_Name__c=a.lastName,                        Date_Of_Birth__c=a.Birthdate,                        Mobile_No__c=a.MobilePhone,                        Email__c=a.Email                        );                        insert ccd;                        }                                                catch(system.DmlException e)                        {                                    System.debug('we caught a dml exception: ' + e.getDmlMessage(0));                            }    }

}

 

please help me, in this regards.... in correct way.

 

Thanks in Advance, 

 

Srinivas Chittela

  • August 27, 2009
  • Like
  • 0