• Claudine Warren 19
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
I have creted the apex class and the call to trigger update and i have also try with before update but in that i occur the proccesinstance comments null
apex class:
 public static void updateComments(List<ASKWA_Documents__c> doclist){
        List<Id> docIds = New List <Id>();
        List<id>processId=new List<id>();
        for (ASKWA_Documents__c docObj: doclist){
            if(docObj.X2nd_Level_Approved__c == 'N'){
                System.debug('approval' +docObj.X2nd_Level_Approved__c);
                docIds.add (docObj.Id);
            }
        }
        List<ProcessInstance> instances = [SELECT Id, TargetObjectId FROM ProcessInstance WHERE TargetObjectId IN :docIds];
        System.Debug ('** instances: '+instances);
        Map<Id,Id> DocProcessMap = new Map<Id,Id>();
        docIds = New List <Id>();
        for(ProcessInstance piObj:instances){
            DocProcessMap.put (piObj.TargetObjectId,piObj.Id); 
            processId.add (piObj.id);
        }
        System.Debug ('** mapa1: '+DocProcessMap);
        System.Debug ('** processId: '+processId);
        string commentStr=''; 
        List<ProcessInstanceStep> instancesSteps = [SELECT Id,Comments,ProcessInstanceId FROM ProcessInstanceStep WHERE ProcessInstanceId IN:processId];
        System.debug('++instancesSteps' +instancesSteps);
        Map<Id,String> DocProcessStepMap = new Map<Id,String>();
        for(ProcessInstanceStep pisObj:instancesSteps){
            System.debug('+++processid'+pisObj.ProcessInstanceId);
            System.debug('+++processid'+pisObj.Comments);
            DocProcessStepMap.put (pisObj.ProcessInstanceId, pisObj.Comments); 
        }
        System.Debug ('** mapa2: '+DocProcessStepMap);
        for (ASKWA_Documents__c docObj: doclist){
            //if (l.X2nd_Level_Approved__c == 'N'){
            System.debug ('** razon2: '+ DocProcessStepMap.get(DocProcessMap.get(docObj.Id)));
            docObj.X2nd_Level_Remark__c = DocProcessStepMap.get(DocProcessMap.get(docObj.Id));
            //System.debug ('** razon: '+docObj.X2nd_Level_Remark__c);
            //}
        } 
    }
please let mi know what is wrong i will not able to update .

hi,

 

   i need to capture the comments that approver gives while approving/rejecting a record. I need to use this field value in a  template and send it to some other user. 

 

                  Can any one gimme merger field syntax to use it in mail template???

 

 

     Thanks in Advance,

nishanth.