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
Brandon Nelson 9Brandon Nelson 9 

Customer APEX Trigger Code Failure

I have a trigger that I need to put in production, but I keep getting the following error. Can someone please look at my trigger and tell me why this is happening?
ERROR: The following triggers have 0% code coverage. Each trigger must have at least 1% code coverage.
Trigger ConvertToClient on Lead_Prospect__c(after insert, after update){
  //Adding the name to the Client record//
     
     List<Client__c> cons =new List<Client__c>();
     String idStore = null;
     Object tId = null;
     for(Lead_Prospect__c a :trigger.new){
     
         idStore = (String)a.id;
         List<Client__c> idChecks = [SELECT Prospect_ID__c FROM Client__c WHERE Prospect_ID__c = :idStore];
       if(a.Convert_to_Client__c == true && idChecks.size() <= 0){
          Client__c c  =new Client__c();
          c.Name = a.Name;
          c.Enagement_Type__c = a.Engagement_Type__c;
          c.Prospect_ID__c = a.id;
          tId = a.id;
           cons.add(c);
        
           }
   }
if (cons.size()>0){
    insert cons;
    Client__c c = [SELECT Prospect_ID__c FROM Client__c WHERE Prospect_ID__c = :idStore];
    Lead_Prospect__c a = [SELECT Client_Name__c FROM Lead_Prospect__c WHERE Id = :idStore];
    a.Client_Name__c = c.id;
    
    update a;
}
}



 
Brandon Nelson 9Brandon Nelson 9
@Zagakuf - My objects don't have a field called Project Manager nor am I storing a contant value anywhere in the APEX. I think you might have replied to the wrong one.
Zagakuf SmithZagakuf Smith
IDs do not carry over from Sandbox to Production. Therefore, it is bad practice to explicitly reference IDs in Apex. In your trigger you have sp.sfdc_project_manager__c = '00550000000n0VZ';.
This is breaking your code most probably. 

With Regards,
Protar Smith
References: kodi.software (https://kodi.software/) | show-box.ooo (https://show-box.ooo/) | dltutuapp.com (https://dltutuapp.com/)