0

Please help me with this. In the second for loop this error is coming

     Map<Id,ProcessInstance> processinstence = New Map<Id,ProcessInstance>([SELECT Id, Status, (SELECT ID, ProcessNodeId,  
                         StepStatus,Comments,TargetObjectId,ActorId,CreatedById,IsDeleted,IsPending  
                         ,OriginalActorId,ProcessInstanceId,RemindersSent,CreatedDate, Actor.Name,  
                         OriginalActor.Name , ProcessNode.Name FROM StepsAndWorkitems)   
                   FROM ProcessInstance where TargetObjectId =:'a002v0000441VOX' order by CreatedDate DESC]); 

     for(ProcessInstance pr :  processinstence.values()){
         For(StepsAndWorkitems  str : pr.StepsAndWorkitems) {
            // wrappercls.add(New WrapperController(pr.Status,str.Comments,str.Comments));
         }
        //
    }
5

StepsAndWorkitems is not a type, it is a child relationship name for ProcessInstanceHistory, so type should be ProcessInstanceHistory and not StepsAndWorkitems.

Excerpt from the salesforce documentation

The nested query references StepsAndWorkitems, which is the child relationshipName for ProcessInstanceHistory in the ProcessInstance object.

You can refer documentation of ProcessInstanceHistory for further information on this topic.

Replace StepsAndWorkitems with ProcessInstanceHistory, so your code should be

Map<Id,ProcessInstance> processinstence = New Map<Id,ProcessInstance>([SELECT Id, Status, (SELECT ID, ProcessNodeId,  
                         StepStatus,Comments,TargetObjectId,ActorId,CreatedById,IsDeleted,IsPending  
                         ,OriginalActorId,ProcessInstanceId,RemindersSent,CreatedDate, Actor.Name,  
                         OriginalActor.Name , ProcessNode.Name FROM StepsAndWorkitems)   
                   FROM ProcessInstance where TargetObjectId =:'a002v0000441VOX' order by CreatedDate DESC]); 

for(ProcessInstance pr :  processinstence.values()){
    for(ProcessInstanceHistory  str : pr.StepsAndWorkitems) {
        // wrappercls.add(New WrapperController(pr.Status,str.Comments,str.Comments));
    }
    //
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.