此触发器从 Process Instance 对象中提取值,将它们存储在列表中,并更新自定义对象上的字段。问题是为了查看值,用户必须更新并保存记录。通常我会在流程实例对象上添加一个“更新后”触发器,但 Salesforce 不允许这样做。
任何帮助或建议将不胜感激。
在 Service_Request__c 上触发 update_Provisioner(更新前){
for(Service_Request__c sr:Trigger.new){
List <ProcessInstance> pi = [SELECT Id, CreatedDate from ProcessInstance where TargetObjectId = :sr.Id ORDER BY CreatedDate DESC limit 1];
List <ProcessInstanceStep> op = [SELECT Id, StepStatus, ActorId, OriginalActorId, CreatedDate FROM ProcessInstanceStep where ProcessInstanceId = :pi[0].Id ORDER BY CreatedDate DESC limit 1];
if(op.size()>0){
//System.debug('Hello'+sr.Provisioner__c+' '+op[0].StepStatus + ' '+ op[0].ActorId + ' ' +op[0].OriginalActorId + ' '+ op[0].CreatedDate);
sr.Provisioner__c = op[0].ActorId;
}
}
}