I am playing around with the mobile sdk and in the mobile sdk sample contactExplorer, i am adding a functionality of getting the chatter feeds of the logged in user.

In my index.html

i added a href tag to display a new link to fetch the chatter feed

<p><a href="#" id="link_fetch_sfdc_chatter" data-role="button" data-inline="true">Fetch Chatter</a></p>

and in the inline.js i added the following code

$j('#link_fetch_sfdc_chatter').click(function() {
                                     logToConsole("link_fetch_sfdc_chatter clicked");
                                            forcetkClient.chatterFeedsCurrentUser(onSuccessSfdcChatter, onErrorSfdc); 

Here i am calling a function to get the feeds and pass the response to callback method onSuccessSfdcAccounts.

here is the chatterFeedsCurrentUser method on my forcetk.mobilesdk.js

  forcetk.Client.prototype.chatterFeedsCurrentUser = function(callback, error) {
alert('calling from forcetk');
    return this.ajax('/' + this.apiVersion + '/chatter/feeds/news/me/feed-items', callback, error);

Here is the onSuccessSfdcChatter method

function onSuccessSfdcChatter(response) {
    var $j = jQuery.noConflict();
    alert('Chatter success method!');
    cordova.require("salesforce/util/logger").logToConsole("onSuccessSfdcChatter: received " + response.totalSize + " Feed Items");


The issue i am facing is that chatterFeedsCurrentUser method is not calling the callback method. The alert 'calling from forcetk' is only displayed after which nothing happens. I am not sure what i am doing wrong here.

I am working on hybrid app on a android.


Your success method is actually named onSuccessSfdcChatter while the method you are registering as a callback with forcetk is called onSuccessSfdcAccounts- make sure you use the correct success method handler name that's registered with forcetk

  • Thanks for pointing that out.. I had originaly had it as onSuccessSfdcChatter and i had changed that out just to see if it was calling the onSuccessSfdcAccounts. In both cases call is not passing into the success methods. So i am thinking that its got to be something in forcetk.Client.prototype.chatterFeedsCurrentUser which is causing the trouble but unable to identify what it is
    – Prady
    Jan 8 '14 at 2:54
  • 1
    This gist has some examples of using forcetk for Chatter feed operations. I would recommend you look at this code, you're definitely missing something if your callback function is not being triggered - gist.github.com/sbob-sfdc/3644128 Jan 8 '14 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.