+ Start a Discussion
moverdorfmoverdorf 

Simple question (I hope)...

I do the following query, to get BOTH closed activites and open ones:

 

SELECT name, id, (SELECT id,ActivityDate,Description,Subject,IsClosed,CallType,CallDisposition,Status,ActivityType

FROM ActivityHistories where isTask = true

 Order by ActivityDate desc

) ,

(SELECT id,ActivityDate,Description,Subject,IsClosed,CallType,CallDisposition,Status,ActivityType

FROM OpenActivities where isTask = true

 Order by ActivityDate desc

)

FROM Account where name like '%Abseck%'

 

The query results are saved in lstactivity

 

I am trying to loop thru and get at the ActivityHistories info

for(Account a : lstactivity)

{

 

   for(ActivityHistory t : a.ActivityHistories)

   {

       System.debug(t.ActivityDate);

   }

}

 

I am getting an error that t.ActivityDate doesn't exist.

am I referencing ActivityHistories correctly in the loop?..I wasn't sure what to use for the names

 

 

When I do it for OpenActivities it works...

for(Account a : lstactivity)

{

 

   for(OpenActivity t : a.OpenActivities)

   {

       System.debug(t.ActivityDate);

   }

}

 

Please hlep!... Thanks in advance.

 

Amol DixitAmol Dixit

Hi,

 

I have tried to execute code in Execute Anonymous and it is working fine without any error.

 

Please try this.

 

list<Account> lstactivity = [SELECT name, id, (SELECT id,ActivityDate,Description,Subject,IsClosed,CallType,CallDisposition,Status,ActivityType
FROM ActivityHistories where isTask = true
Order by ActivityDate desc
) ,
(SELECT id,ActivityDate,Description,Subject,IsClosed,CallType,CallDisposition,Status,ActivityType
FROM OpenActivities where isTask = true
Order by ActivityDate desc
)
FROM Account];

 


for(Account a : lstactivity)
{

for(ActivityHistory t : a.ActivityHistories)
{
System.debug('Test Debug log'+t.ActivityDate);
}
}

 

 

Warm Regards,

Amol Dixit.

Sagarika RoutSagarika Rout

This query is perfectly ok and working fine....(Through work bence it is runing with out error for both the object OpenActivity and

ActivityHistory as well)

 

 

 

Sagarika Rout

SFDC Developer

moverdorfmoverdorf

I tried cutting and pasting and I get an error saying:

 

Variable does not exist  "ActivityDate".

 

Does anyone else out there get this if they try it in their org?

 

Thanks so much for the help.