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
vishalavishala 

unable to query steps of Process Instance in before/after update trigger

Trying to query the ActorId from Steps, but getting null

 

Trigger getApprover on customObj__c(before Update){

 

List<customObj__c> test=Trigger.new;

 

processInstances = [select (select ActorId,OriginalActorId from Steps order by CreatedDate desc)
                                        from ProcessInstance where TargetObjectId =: test[0].Id];

Id Qid  = processInstances[0].Steps[0].OriginalActorId;

 

test2=[Select Queue.Name from QueueSobject where QueueId =: Qid];

 

}

 

Qid is null, when I am trying to submit a record for approval,

throughing an error: List has no rows for assignment to Sobject.

Why is that subquery results are blank.

Any help would be appreciated to fetch the ActorId for that Process Instance.

 

Thanks,

Vishala