Since today morning i am getting following error whenever i try to open any opportunity.

Object type not accessible. Please check permissions and make sure the object is not in development mode: There is an implementation restriction on ActivityHistories. When you query this relationship, security evaluation is implemented for users who don't have administrator permissions, and you must use a specific sort order: ActivityDate DESC, LastModifiedDate DESC

I have compared opportunity pages and classes with local history but didn't find any difference.

Profile is also not got changed. Can any one please help

  • Have you looked under Setup-> Security -> View Setup Audit Trail to see if anything in your Org has been changed that might have caused this?
    – crmprogdev
    Commented Sep 8, 2014 at 22:00
  • 1
    Pramod -- looks like you found this post - salesforce.stackexchange.com/a/25014/2602 Was that not helpful? Did your org migrate a 'whole mess' of tasks onto your Opportunities very recently? The error is indicative of a query being executed that would return too much data for your user profile
    – cropredy
    Commented Sep 9, 2014 at 0:26
  • @crmprogdev I have extracted audit tail but didn't find any suspected thing in that. Commented Sep 9, 2014 at 4:58
  • @crop1645 yes i see this post but could not solve my problem. No i have not migrated any thing from and to my current org Commented Sep 9, 2014 at 5:00
  • Only two other things come to mind. 1. look and see how many records you have in your database to see if you're approaching the limits. 2. Use a freebie metadata utility to find any queries on Opportunity with History and check for sort order. The latter of course could be performed by standard controllers and may not be esp productive. Am otherwise out of ideas.
    – crmprogdev
    Commented Sep 9, 2014 at 5:17

2 Answers 2


I ran into same issue on non-admin profiles only.

This article from salesforce explains it well: http://www.salesforce.com/developer/docs/api/Content/sforce_api_objects_activityhistory.htm

These last few lines are golden words and should be in bold in salesforce docs:

  • In the inner clause of the query, you must specify a limit of 500 or fewer on the number of rows that are returned in the list.
  • In the inner clause of the query, you must sort on ActivityDate in descending order and LastModifiedDate in descending order. You can optionally display nulls last. For example: ORDER BY ActivityDate DESC NULLS LAST, LastModifiedDate DESC.

So your nested activityhistory query should look like this to work, you can also keep 'with sharing' key word on the apex class (as suggested in some other threads, removing it is not at all needed)

   (SELECT ActivityDate, Description 
    FROM ActivityHistory 
    ORDER BY ActivityDate DESC NULLS LAST, LastModifiedDate DESC 
    LIMIT 500)
FROM Account
WHERE Name = 'Acme'
  • thank you for the reply. My code is fulfilling all these above mentioned criteria. Actually i started getting this issue as soon as my org was got updated for winter 15. A day before this upgrade everything was working fine but next day i started getting this error. i compared by file with local history but there was no difference. I faced the same issue on production org as well when it was got updated with winter 15 release. Commented Nov 19, 2014 at 8:03

The same error started to show in our sandboxes as well. The only difference is that when we commented out all references to activity history in the page, the error went away.

Check if your instance is on Winter preview, we think it has something to do with winter preview.

Also, check if you have any references to activity history that might not be so obvious, like through VF components and similar.

I will update this post as soon as I get some more info.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .