function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
tggagnetggagne 

sforce.connection.query returns InvalidType for CollaborationGroupMember object

Super simple page, but when I run it I get an exception, "sObject type 'CollaborationGroupMember' is not supported."  I'm able to query other objects, and Googling around I haven't found an explanation why--or I'm Googling the wrong terms.

However, this link might suggest such a query from VF just isn't possible.
http://salesforce.stackexchange.com/questions/3574/receive-this-error-from-installed-package-system-queryexception-sobject-type
 
<apex:page >
	<apex:includescript value="/soap/ajax/33.0/connection.js" />
	<apex:includescript value="/soap/ajax/33.0/apex.js" />
	
	<script>
		try { 
			var query = "select collaborationGroupId, collaborationGroup.name from CollaborationGroupMember where memberid = '{!$User.ID}'"
			//var query = "select id from account";
			alert(query);
			
			//sforce.connection.sessionId = "{!$Api.Session_ID}";
			var records = sforce.connection.query(query); 
			
			console.log(records); 
		} 
		catch(e) { 
			alert(e); 
		}
	</script>
</apex:page>

 
tggagnetggagne
I got it working with a controller, but it still doesn't answer the question, "Why can't I use sforce.connection.query() against CollaborationGroupMember?"

The new page:
<apex:page controller="MyGroupsFB03186Controller" >
	<apex:repeat value="{!myChatterGroups}" var="each" >
		<apex:outputLink value="/{!each.collaborationGroupId}">{!each.collaborationGroup.name}</apex:outputLink><br />
	</apex:repeat> 
</apex:page>

The new controller:
 
public with sharing class MyGroupsFB03186Controller extends XedeController {
	public MyGroupsFB03186Controller() {
		myChatterGroups = [
			select	collaborationGroupId, collaborationGroup.name 
			  from	CollaborationGroupMember
			 where	memberid = :UserInfo.GetUserId()
		];
			
	}

	public list<CollaborationGroupMember> myChatterGroups { get; private set; }
}

 
pigginsbpigginsb
I recently encountered this error. Certain users could successfully query against ApexPage, while others received the "not supported" error. Enabling the "View Setup and Configuration" permission on the affected User's Profile would prevent this error, but there is obviously more to consider before regarding this as a solution.