• Lili Chaves 2
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hey there! 

I copied @Todd Kadas Trigger code from this forum: 
https://developer.salesforce.com/forums/?id=906F00000005G3yIAE

and tweaked it so it would work on SBQQ__Quote__c object in my org. But I have no idea how to build a test class so I can deploy it to prod. Can someone please help? 
 
trigger TriggerApprover on SBQQ__Quote__c (before update) {
    
       if(trigger.isUpdate){
             List<SBQQ__Quote__c> quoteList =  [Select id,
                                                   (Select Id, 
                                                         IsPending, 
                                                         ProcessInstanceId, 
                                                         TargetObjectId, 
                                                         StepStatus, 
                                                         OriginalActorId, 
                                                         ActorId, 
                                                         RemindersSent, 
                                                         Comments, 
                                                         IsDeleted, 
                                                         CreatedDate, 
                                                         CreatedById, 
                                                         SystemModstamp 
                                                    FROM ProcessSteps
                                                ORDER BY CreatedDate DESC) 
                                                    From SBQQ__Quote__c
                                                WHERE Id IN : Trigger.new];

             if(quoteList.size() > 0){

               for(SBQQ__Quote__c qt : quoteList){
              
                for(SBQQ__Quote__c qt1 : Trigger.new) {
                  
                         //check copy comment is true
                         if(qt.id == qt1.id && qt1.copy_comment__c) {
 
                           if (qt.ProcessSteps.size() > 0) {
                            
                         qt1.Approver_Comment__c = qt.ProcessSteps[0].Comments;
                         qt1.copy_comment__c = false;
                
                           }

                        }
                 
                    }
               }
             }   
        }  
    }

 
Hey there! 

I copied @Todd Kadas Trigger code from this forum: 
https://developer.salesforce.com/forums/?id=906F00000005G3yIAE

and tweaked it so it would work on SBQQ__Quote__c object in my org. But I have no idea how to build a test class so I can deploy it to prod. Can someone please help? 
 
trigger TriggerApprover on SBQQ__Quote__c (before update) {
    
       if(trigger.isUpdate){
             List<SBQQ__Quote__c> quoteList =  [Select id,
                                                   (Select Id, 
                                                         IsPending, 
                                                         ProcessInstanceId, 
                                                         TargetObjectId, 
                                                         StepStatus, 
                                                         OriginalActorId, 
                                                         ActorId, 
                                                         RemindersSent, 
                                                         Comments, 
                                                         IsDeleted, 
                                                         CreatedDate, 
                                                         CreatedById, 
                                                         SystemModstamp 
                                                    FROM ProcessSteps
                                                ORDER BY CreatedDate DESC) 
                                                    From SBQQ__Quote__c
                                                WHERE Id IN : Trigger.new];

             if(quoteList.size() > 0){

               for(SBQQ__Quote__c qt : quoteList){
              
                for(SBQQ__Quote__c qt1 : Trigger.new) {
                  
                         //check copy comment is true
                         if(qt.id == qt1.id && qt1.copy_comment__c) {
 
                           if (qt.ProcessSteps.size() > 0) {
                            
                         qt1.Approver_Comment__c = qt.ProcessSteps[0].Comments;
                         qt1.copy_comment__c = false;
                
                           }

                        }
                 
                    }
               }
             }   
        }  
    }