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
mms.testsmms.tests 

How to get all groups a user belong using SOQL in forcetk client?

I am using forcetk.mobilesdk.js to develop a chatter app.

 

Tried to get group using following method:

$j('#link_fetch_sfdc_group').click(function() {
logToConsole("link_fetch_sfdc_group clicked");
forcetkClient.query("select Name, Type, OwnerId from Group", onSuccessSfdcGroup, onErrorSfdc);
});

 

I can't the group created by me. I got 37 groups returned, but none of them are my groups. And all of them have empty "Name" attribute. What have I done wrong? How can I retrieve groups I belong to?

 

thanks!

Best Answer chosen by Admin (Salesforce Developers) 
jody_blyjody_bly

Sorry, I haven't used ForceTK. But if you're working in a Visualforce page, you might want to use the classes in the Apex ConnectApi namespace (also called "Chatter in Apex") to access the data without making an HTTP call:

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_connect_api.htm

 

 

All Answers

jody_blyjody_bly

To get informaiton about Chatter groups, use the CollaborationGroup object. 

 

You could also use Chatter REST API:

https://{server_instance}/services/data/v29.0/chatter/users/me/groups

 

http://www.salesforce.com/us/developer/docs/chatterapi/Content/connect_resources_users_UserGroups.htm

mms.testsmms.tests

Thanks very much for the quick reply. CollaborationGroup works!

 

Another question, I tried to use the forceTk.client.ajax() to make calls to the ".../users/me/groups" directly, but the response.totalSize and response.responseText in the callback method are returned "undefined".  When I use SOQL, those values are there.

 

Any idea why? the response object itself is an object.

 

Thanks in advance!

jody_blyjody_bly

Sorry, I haven't used ForceTK. But if you're working in a Visualforce page, you might want to use the classes in the Apex ConnectApi namespace (also called "Chatter in Apex") to access the data without making an HTTP call:

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_connect_api.htm

 

 

This was selected as the best answer