I am getting the error –
'System.QueryException: sObject type 'CollaborationGroup' is not supported.'
When running the following code as part of a managed package by scheduled apex:
List groups = [select id, name, description from
collaborationGroup];
What's strange is that the code works if I run it in the developer console but not when it runs from scheduled apex (setup as part of a post install script).
I've got 'with sharing on' so could it be down to the installer user profile? It works in some installed instances but not others but can't see a reason e.g. SFDC edition, profile, chatter settings, etc…
I do know that Chatter has to be enabled but that is the case anyway in the partnerforce dev orgs.
What am I missing here?
Best Answer
Your code must be run in a
without sharing
context in order for it to have access to theCollaborationGroup
SObject. I'm guessing that your Utility class which contains the query is not explicitly declared aswithout sharing
, so you can do one of two things:InstallHandler
).without sharing
.without sharing
.