You need to sign in to do that
Don't have an account?

sObject type 'recentlyviewed' is not supported
Query : select id , name from recentlyviewed where type = 'Account'
I just have a custom account page built.The given query is working fine in dev console and on UI but not in the test class.
When I try to load the recently viewed records from the recently viewed object in a test class then it gives the following error message.
Error Message: sObject type 'recentlyviewed' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.
I am not sure why i am not able to access this object using in a test class ??
Any help is appreciated!
I just have a custom account page built.The given query is working fine in dev console and on UI but not in the test class.
When I try to load the recently viewed records from the recently viewed object in a test class then it gives the following error message.
Error Message: sObject type 'recentlyviewed' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.
I am not sure why i am not able to access this object using in a test class ??
Any help is appreciated!
Thanks for the reply.I am using API version 32.Any other idea why is it still happening ?
I've come across this same issue in the past as well, and most recently hit the issue today while writing test classes for some new controllers I've implemented. As this is a compiler error, I was able to resolve the issue by removing explicit references to the RecentlyViewed object in my controller code. See below for an example.
Original code:
Revised code:
For my specific use case, I am not doing much with the recently viewed records in my controller beyond serving them up to the visualforce page for viewing purposes, etc., so I was able to take it a step further and add a check that prevents the query from ever executing if the current context is a test. The result is that my page tests will always run with 0 results returned for recently viewed records from my custom object, but for my specific use case, it does not truly impact the integrity of my tests. I can understand and appreciate that some folks may not find this last part desirable, however, given their specific use case.
I hope this is helpful!