List<sObject> activityRows = obj.getSObjects(activityType);
Here activitytype is nothing but openactivity and closedactivity.
I am wondering why am I getting this error. However I am not using any of the aggregate functions. After research, I found that it is because of the inner query I am using. But this error is getting if there are 500+ task records for the account.
Here is the query I am using
SELECT Id, Name, ( SELECT Id, AccountId, AlternateDetailId, ActivityDate, ActivitySubtype, ActivityType, Description, EndDateTime, IsTask, OwnerId, Owner.Name, PrimaryAccountId, PrimaryWho.Name, PrimaryWhoId, ReminderDateTime, StartDateTime, Status, Subject, WhatId, WhoId, Type__c FROM OpenActivities ORDER BY ActivityDate ASC NULLS FIRST, LastModifiedDate DESC LIMIT 500 ), ( SELECT Id, AccountId, AlternateDetailId, ActivityDate, ActivitySubtype, ActivityType, Description, EndDateTime, OwnerId, IsTask, Owner.Name, PrimaryAccountId, PrimaryWho.Name, PrimaryWhoId, ReminderDateTime, StartDateTime, Status, Subject, WhatId, WhoId, Type__c FROM ActivityHistories ORDER BY ActivityDate DESC NULLS FIRST, LastModifiedDate DESC LIMIT 500) from account where id='09845678'
sObject obj = Database.query(querystring)
Later I changed it to for loop like below
list<sObject> activityRows = new List<SObject>();
System.debug('activityType:1 '+activityType);
for(sObject objOpen: obj.getSObjects('OpenActivities')){
activityRows.add(objOpen);
}
That I am getting this exception Invalid Querylocator
Note This exception only comes when there are 499+ records
I have been sitting with this for the past 1 day. Please share your idea it will be helpful for me.