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
Bundit Phetplay 15Bundit Phetplay 15 

Capture all of 'Approver's Comment' to each field at each steps (Not after final approver approved the record)

Dear All,

Here is my requirement

- Capture All of Approver comment of each step

- Display the previous approver and below the layer to the approver in email (For example if approver in step 4., He wants to see the comment from step 1 2 and 3 'without' open the SFDC record <--- This point I aim to capture the comment and send the email)

My problem is my very simple trigger works only at the end of the approval process with only lastest comment, I try to add 'Field Update' action to '1st Approvers Approve' but it's not working, Can anyone can suggest me or revise my code? (Maximum of my approval layer is 5)

Here is my very simple trigger

Note that copy_comment__c is a checkbox field to fire a trigger via the approval process

and Approver_Comment__c is a field to keep the comment (maybe I need to create 4 more of this fields to stamp all of 5 approver's comment)

trigger TriggerApprover on Quote (before update) {
    
       if(trigger.isUpdate){
             List<Quote> QuoList =  [Select id,
                                                   (Select Id, 
                                                         IsPending, 
                                                         ProcessInstanceId, 
                                                         TargetObjectId, 
                                                         StepStatus, 
                                                         OriginalActorId, 
                                                         ActorId, 
                                                         RemindersSent, 
                                                         Comments, 
                                                         IsDeleted, 
                                                         CreatedDate, 
                                                         CreatedById, 
                                                         SystemModstamp 
                                                    FROM ProcessSteps
                                                ORDER BY CreatedDate DESC) 
                                                    From Quote
                                                WHERE Id IN : Trigger.new];

             if(QuoList.size() > 0){

               for(Quote quo : QuoList){
              
                for(Quote quo1 : Trigger.new) {
                  
                         //check copy comment is true
                         if(quo.id == quo1.id && quo1.copy_comment__c ) {
 
                           if (quo.ProcessSteps.size() > 0) {
                            
                         quo1.Approver_Comment__c = quo.ProcessSteps[0].Comments;
                         quo1.copy_comment__c = false;
                
                           }

                        }
                 
                    }
               }
             }   
        }  
    }
Pavit SiddhuPavit Siddhu
Hello, Bundit

Are you update copy_comment__c field on every approval? If not then create separate field update( copy_comment__c =true) after every approval, And I think no need to create separate comment field. You can concatenate String with approval number and separator like (,) and split when you want to show anywhere.

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved.

Thanks and Regards
Pavit Siddhu
Bundit Phetplay 15Bundit Phetplay 15

Hi Pavit Siddhu,

Actually, I plan to do only Quote obj and stamp on every Approver's comment and

Well, I already consult with SFDC Support He said that Trigger that I write will work 'after' final approver already approved (means add field update to trigger the trigger at 1st or 2nd approver is not working) I search some website they suggest to use Future Method but I not really sure about how to use the future method

In addition, he suggested me to use "Approval process + Process Builder + InvocableMethod" instead of "Approval Process + Trigger" but I struct with the error message

"Can’t Save Record
We can't save this record because the “copy comment for QUOTE” process failed. Give your Salesforce admin these details. An unhandled fault has occurred in this flow
An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information. Error ID: 641183419-69039 (-725825571) "

And the error via email is System.LimitException: Too Many Query Rows: 50001

Munna vikramMunna vikram
This website has great information about downloading and installing the Roblox online game. roblox hack download (https://freerobuxplace.xyz/) So visit here and know how to download the Roblox online game free of cost this is an amazing post for the user.