0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

承認者のコメントをカスタムフィールドに追加する方法

Posted at

I think it is possible by using Apex trigger.

Capture an approval comments to populate a lead custom field
https://developer.salesforce.com/forums/?id=9060G000000I3uzQAC

List<Id> pId = new List<Id>();

        Map<Id,ProcessInstance> xyz = new Map<Id,ProcessInstance>();

        Map<Id,ProcessInstanceStep> abc = new Map<Id,ProcessInstanceStep>();

        for(ProcessInstance pi : [SELECT Id,Status,TargetObjectId FROM ProcessInstance WHERE TargetObjectId =: newmap<object>.keySet() ORDER BY CreatedDate DESC]){

            if(!xyz.containsKey(pi.TargetObjectId)){

                xyz.put(pi.TargetObjectId,pi);

                pId.add(pi.Id);

            }

        }

        for(ProcessInstanceStep pis : [SELECT Id, Comments,ProcessInstanceId, StepStatus, OriginalActorId, ActorId FROM ProcessInstanceStep WHERE ProcessInstanceId IN: pId]){

            if(!abc.containsKey(pis.ProcessInstanceId))

 abc.put(pis.ProcessInstanceId, pis);   

        }

        system.debug('ProcessInstanceStep'+abc);

        system.debug('ProcessInstance'+xyz);

        

        for(<obj> abxy : lstOfNew<obj>) { 

            if(conditions if any) {

                

                ProcessInstance p = .get(abxy.Id);

                if(conditions if any)  

                

 system.debug('anyname'+abc.get(p.Id).Comments);

 <field that u want the comments> = abc.get(p.Id).Comments;

                    

                }

            }        

        }
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?