+ Start a Discussion
moverdorfmoverdorf 

How To Access Fields From Return Result Of OpenActivites

Hi guys, running the SOQL query below, and when I look at the Debug message that comes back I can see the OpenActivities object and

all the fileds in my SELECT statement. Now I would like to know the SYNTAX of how to get at the individual columns of the OpenActivities

result.

 

I tried something like this:

system.debug(a.OpenActivities.ActivityDate); - causes an error

 

So what is the correct syntax for getting at the ActivityDate value?

 

 

List<Account> lstactivity = new List<Account> ([
SELECT (SELECT
         ActivityDate,
         Description,
         Subject,
         IsClosed,
         CallType,
         CallDisposition,
         Status,
         ActivityType
        FROM OpenActivities
         
        )
FROM Account
]
);


for (Account a: lstactivity) {
     //msg = a.OpenActivities.status;
    system.debug(a.OpenActivities);
}

sfdcfoxsfdcfox
OpenActivities is a list of elements, even if there is only one record. You should iterate over OpenActivities in a loop.
moverdorfmoverdorf

Yes, but please show me the code to do this. I am not quite sure the syntax I need to accomplish this.

 

Thanks.

moverdorfmoverdorf

Can you please give me the code to loop through the OpenActivities in a loop. I am a liitle confused about the syntax.

 

Thanks so much.