function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Del_SantosDel_Santos 

Help on trigger deployment

Hi Guys,

 

I am deploying  below trigger in our production but im always getting "Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required". This is my first time creating a trigger could someone help me please.

 

trigger twebLead on Lead (after update) {
   if (Trigger.new.size() == 1) {
     if (Trigger.old[0].isConverted == false && Trigger.new[0].isConverted == true) {
      if (Trigger.new[0].ConvertedAccountId != null) { 
        Account a = [Select a.Id, a.CurrencyIsoCode From Account a Where a.Id = :Trigger.new[0].ConvertedAccountId];
        a.CurrencyIsoCode = 'PHP';
        update a;
      }
     
      if (Trigger.new[0].ConvertedOpportunityId != null) {
        Opportunity o = [Select o.Id, o.CurrencyIsoCode from Opportunity o Where o.Id = :Trigger.new[0].ConvertedOpportunityId];
        o.CurrencyIsoCode = 'PHP';
        update o;
      }
    }
  }
}

 

I don't know what i am missing since i have deployed the same code in sandbox and worked well.

 

Thanks,

Del

Navatar_DbSupNavatar_DbSup

Hi,

 

You will have to create test class for this trigger then deploy both (trigger and test class) in production.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

Del_SantosDel_Santos

Thanks, can you give me a sample on how should i begin this? :( sorry