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
Vignesh RamshettyVignesh Ramshetty 

Showing if i use child name

 List<ProcessInstance> listview = [SELECT Id, TargetObject.Name,CreatedDate,TargetObjectId,(SELECT Id, ActorId, ProcessInstanceId FROM Workitems WHERE Actor.Name = 'Mala Srinivas'),(SELECT Id, StepStatus, Comments FROM StepsAndWorkitems),SubmittedBy.Name,SubmittedById,Status, LastModifiedDate FROM ProcessInstance where Status='Pending'];


for(ProcessInstance:listview){
             for (ProcessInstanceHistory history : pri.StepsAndWorkitem) {
                 //Need to get comments out of the queary
             }

}

//queary is working good but if i loop unable to get the data of child object

Getting error = Variable does not exist: StepsAndWorkitem;
HarshHarsh (Salesforce Developers) 
Hi Vignesh,
  •  There is a type in your code.
  • The child relationship is named "StepsAndWorkitems" in your SOQL query.
  • But in your loop, you are trying to access it using "StepsAndWorkitem."
  • The correct reference should be "StepsAndWorkitems."
Please mark it as Best Answer if the above information was helpful.

Thanks.


Heads up about the Forums shut down

User-added image
Important Update

We appreciate your participation in these Salesforce Discussion Forums! It’s active members like you that keep our amazing community going strong.

At this time, we want to give you a heads up that on December 4, 2023, the discussion forums will shut down and all relevant discussions will migrate to the Trailblazer Community digital platform. This move brings all conversations around Salesforce development together in one place and provides more opportunities for our broader community to connect and share. We will be removing outdated, obsolete, or spam content and migrating only relevant discussions to the Trailblazer Community digital platform.

Starting November 20, you can view discussions but not post new questions or responses. On December 2, you will no longer be able to access the discussion forums from the Salesforce Developers website.

Please take these steps before November 30, 2023, 11:59 p.m. PT to ensure your contributions follow you to the Trailblazer Community:
  1. If you’re not already a member of the Trailblazer Communitysign up for a Trailblazer account using the same login email address associated with your Developer Discussion Forums account. This is crucial.
  2. If you already have a Trailblazer account, and it’s using a different email address from the one you used for your Developer Discussion Forums account, we recommend that you log in to the Trailblazer Community and connect your forums email address to your Trailblazer account.
Once you’re in the Trailblazer Community, join the Migration Support Hub users group to help you navigate this transition.

We will keep you up to date throughout the transition, and we look forward to seeing you joining the developer discussions in the Trailblazer Community!

Sincerely,
The Forums Support Team
Vignesh RamshettyVignesh Ramshetty
 List<ProcessInstance> listview = [SELECT Id, TargetObject.Name,CreatedDate,TargetObjectId,(SELECT Id, ActorId, ProcessInstanceId FROM Workitems WHERE Actor.Name = 'Mala Srinivas'),(SELECT Id, StepStatus, Comments FROM StepsAndWorkitems),SubmittedBy.Name,SubmittedById,Status, LastModifiedDate FROM ProcessInstance where Status='Pending'];


for(ProcessInstancepri :listview){
             for (ProcessInstanceHistory history : pri.StepsAndWorkitems) {
                 //Need to get comments out of the queary
             }

}

no it was not working then i tried to use by removing 's' it not woking giving error