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
Debendra Ray 8Debendra Ray 8 

Not able to deploy component in production instance , which is uploaded from the sandbox

Please help me resolve the following errors in the deployment settings of the production :

Component Errors

 

API Name
Type
Line
Column
Error Message
0 0 TestAllClass.Test_ApprovalCommentTrackOnQuote(); TestAllClass.Test_Stageupdate_Quote(), Details: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process was found.: []: [] Class.TestAllClass.Test_ApprovalCommentTrackOnQuote: line 254, column 1; System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process was found.: []: [] Class.TestAllClass.Test_Stageupdate_Quote: line 164, column 1
0 0 SendEmailForTaskEscalation, Details: Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is requiredPrevious (1 - 2 of 2) NextApex Test Failures

 

Class Name
Method Name
Error Message
TestAllClass Test_ApprovalCommentTrackOnQuote System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process was found.: []: []
Stack Trace: Class.TestAllClass.Test_ApprovalCommentTrackOnQuote: line 254, column 1
TestAllClass Test_Stageupdate_Quote System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process was found.: []: []
Stack Trace: Class.TestAllClass.Test_Stageupdate_Quote: line 164, column 1
Best Answer chosen by Debendra Ray 8
Debendra Ray 8Debendra Ray 8
Dear Art,

Thanks very much. Appreciate it.

Regards,

Debendra

All Answers

ManojjenaManojjena
Hi Debendra,
 R u deploying any workflow email alert or any field update which is used in your approval process ?
Debendra Ray 8Debendra Ray 8
Hi Manoj,

I'm trying to deploy a trigger in the Production, which is defined on TASK which will send emails when the task is not completed within the due date.

Thanks.

Regards,

Debendra
ManojjenaManojjena
HI Debabrata ,

It will better if you will raise a case to salesforce or try again after some time with new chain set . or try from eclipse once .
As it is a internal error from salesforce .
Art SmorodinArt Smorodin
HI Debabrata,

Looks to me that it might be one of the validation rules you have on your Task object. I had simmilar issues with my Opportunity object validation rules. Every time I tried to migrate Trigger/Class into Prod, this validation rule would prevent me from doing that. 

First my solution was to manually disable this rules before validation and deployment, and re-enable it after it was complete. Later I found a way to do it using Custom Settings.

 Navigate to Customize -> Activities -> Task Validation Rules and see if you have any. You can either disable them all, or to trial and error untill you find the one you need. 

Best,
Art.
Debendra Ray 8Debendra Ray 8
Hi Art,

Thanks - This solved part of the problem during deployement, however, I am still getting an error - - SendEmailForTaskEscalation, Details: Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required.

Please could you inspect the following code and suggest how to improve the code coverage % :
trigger SendEmailForTaskEscalation on Task (after update) {
    
    for (Integer i = 0; i < Trigger.new.size(); i++) {
         try{
             
             if( Trigger.new[i].CallDisposition == 'Escalated to Manager' &&
                 Trigger.new[i].Status != 'Completed'  &&
                 Trigger.new[i].ActivityDate <= date.today()
               ) {
           
                     sendEmailToManager(Trigger.new[i]);  
                     System.debug('SendEmailForTaskEscalation -> Email Send to Manager');
               }else{
                   
                   System.debug('SendEmailForTaskEscalation -> Email Not Send to Manager');
               }
         }catch(Exception e)
         {
            Trigger.new[i].addError(e.getMessage());
            System.debug('Error : SendEmailForTaskEscalation ->'+ e);  
         }
    }
    
    // This method will submit the proposal automatically
    public void sendEmailToManager(Task tsk){
        
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String ownerName = [select Name from User where Id = :tsk.OwnerId].Name;
        String emailAddr = [select Email from User where Id = :tsk.OwnerId].Email;
        String userManagerId = [select ManagerId from User where Id = :tsk.OwnerId].ManagerId;
        String userManager = [select Name from User where Id = :userManagerId].Name;
        String userManagerEmail = [select Email from User where Id = :userManagerId].Email;
        
        String[] toAddresses = new String[] {userManagerEmail};
        String[] ccAddresses = new String[] {emailAddr};    
        mail.setToAddresses(toAddresses);
        mail.setCcAddresses(ccAddresses);
        
        mail.setSubject('SLA breach for the Task assigned to the User : ' + ownerName );
        mail.setHtmlBody('<br/>Hi,<br/><br/>This is to inform you that, ' + ownerName + ' has failed to complete the following task within the due date :<br/><br/> Due Date of the task :' +tsk.ActivityDate+'<br/>'+'Priority of the task : <b>' + tsk.Priority + '</b><br/> Subject : <b>' +  tsk.Subject  + '</b>'+'</b><br/> Description : <b>' +  tsk.Description +'</b>'+'</b><br/> Status : <b>' +  tsk.Status  + '</b> <br/><br/><br/>Thanks & Regards <br/> <br/>Salesforce Administrator');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

        
    }
    
          
}

Thanks,

Debendra
Art SmorodinArt Smorodin
Hi Debendra,

Try using this (it is not perfect but should do the trick). But before please replace user ID on LINE 14 with your own, of some other active user you have in your system. 
 
@isTest
    public class ForTaskEscalation_Test {
        static testmethod void insertTask(){
        
            List<Opportunity> opp = new List<Opportunity>{ new opportunity(
            name = 'test opp 1', 
            StageName = 'Prospecting',
            CloseDate = system.today()) };
                                
            insert opp;
            
            List <Task> t = new List <Task> { new task(            
            WhatID = opp[0].id,
            OwnerId = '005o00000012E2f',
            CallDisposition  = 'Test',
            Subject = 'Test',
            ActivityDate = Date.today(),
            Status = 'Not Started')};
            
            insert t;
            
            List<task> taskstoupdate = New List<task>{ [select id from task where id =:t]};
            for(task tOK: taskstoupdate ){
                
                tOK.Status = 'In Progress';
                tOK.ActivityDate = date.parse('12/27/2009');
                tOK.CallDisposition = 'Escalated to Manager';
                
            }
            
            update taskstoupdate ;

         
        }
        

    }

 
Debendra Ray 8Debendra Ray 8
Dear Art,

Thanks very much. Appreciate it.

Regards,

Debendra
This was selected as the best answer