0

Its my first attempt at developing a mobile app. I am using the salesforcemobile sdk and the sample app Contact Explorer within the sdk.

I am trying to get the latest feeds of the current user.

I am able to build the url and pass it out, the question i do have is how would i parse the response object.

function onSuccessSfdcChatter(response) {
var $j = jQuery.noConflict();
cordova.require("salesforce/util/logger").logToConsole("onSuccessSfdcChatter: received " + response.totalSize + " chatter");

$j("#div_sfdc_chatter_list").html("")
var ul = $j('<ul data-role="listview" data-inset="true" data-theme="a" data-dividertheme="a"></ul>');
$j("#div_sfdc_chatter_list").append(ul);

ul.append($j('<li data-role="list-divider">Salesforce Chatter: ' + response.totalSize + '</li>'));
$j.each(response.records, function(i, contact) {
       var newLi = $j("<li><a href='#'>" + (i+1) + " - " + contact.name + "</a></li>");
       ul.append(newLi);
       });

$j("#div_sfdc_chatter_list").trigger( "create" )
}

While looping through the response object, $j.each(response.records, function(i, contact) { I am not sure what is that i need to have instead of contact. When the response object returns a contact object i can loop through like i have it now. But when the response returns a feed Item page, how do i loop through to get the latest feed items

Thanks

2

They key here is that the Chatter Feed-Items is returned as an Array (assuming you are accessing any /vxx.0/chatter/feeds/record/xx/feed-items endpoint. The JSON to array handling is done by the Mobile SDK for you. You should then parse it as a regular array (records based on the @items key) received in the response.

Here's an example of how to do it in a native app built using the force.com iOS SDK

| improve this answer | |

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.