Showing posts with label chatter. Show all posts
Showing posts with label chatter. Show all posts

Monday, September 13, 2010

Deleting chatter feeds and comments

Recently I was working on some chatter stuff where i come across the requirement of deleting some chatter feeds (FeedPost) and comments(FeedComment). I try to delete these by making a direct query to the FeedPost and FeedComment object having the ids which i want to delete. But here comes the limitation.

Given post focus on deleting the feeds and comments, while taking these limitation in consideration.

Deleting FeedPost: FeedPost represents the following types of changes in a NewsFeed, UserProfileFeed, or record feed, such as AccountFeed: status updates, text posts, link posts, and content posts.

Limitation: One can't directly query for a FeedPost. FeedPosts are always associated with a feed item, so you can query for them through the feeds.

The following example returns all feed items for a given account, ordered by date descending:

SELECT Id, Type, FeedPost.Body FROM AccountFeed WHERE ParentId = AccountId ORDER BY CreatedDate DESC


So to delete FeedPosts we need to first query for it using its associated feed item and FeedPostsId as shown in the example below. Deleting the feed item will delete all the associated feeds.


List accountFeeds = [Select ParentId, Id, FeedPost.ParentId, FeedPostId From UserFeed where ParentId=: userid and FeedPostId=:chatterParentFeedId];
if(accountFeeds != null) {
delete accountFeeds;
}



Note: NewsFeed does not support delete call. It represents a Chatter feed on a user's home tab. A Chatter feed shows recent changes to records that the user is following.

Deleting FeedComment: A FeedComment is a child object of an associated UserProfileFeed, NewsFeed, or object feed, such as AccountFeed.

Limitation: One can't query FeedComment records directly. They can only be queried via the parent NewsFeed, UserProfileFeed, or entity feed, such as AccountFeed.

The following query returns information, including child FeedComment records:


SELECT ID, CreatedDate, CreatedById, CreatedBy.FirstName, CreatedBy.LastName, ParentId, Parent.Name,
(SELECT CommentBody, FeedItemId FROM FeedComments ORDER BY ID DESC)
FROM NewsFeed
ORDER BY CreatedDate DESC, ID DESC
LIMIT 20


So if we want to delete the comments associated with feed items, one need to query the feed item such as AccountFeed, NewsFeed etc along with FeedComments (filtered using comment id if available to get specific FeedComment record). The below example queries NewsFeed object along with the FeedComment object using the chatterNewsFeedId and chatterCommentId to get specific FeedComment object record to delete.


NewsFeed newFeed = [SELECT Id, (SELECT Id, CommentBody, CreatedDate, CreatedById, CreatedBy.FirstName, CreatedBy.LastName FROM FeedComments where id=:chatterCommentId) FROM NewsFeed where id=:chatterNewsFeedId];
if(newFeed != null) {
List comments = newFeed.FeedComments;
if(comments != null && comments.size() > 0) {
delete comments;
Apexpages.addMessage(new Apexpages.Message(Apexpages.severity.INFO, 'deleted successfully'));
}
}


Similarly one can query for the FeedComment objects using different feed items such AccountFeed, ContactFeed, UserProfileFeed etc. as per the requirement.

Saturday, July 24, 2010

Chatter messenger todo notes

Chatter messenger apps was developed as part of chatter challenge. Its code is available at code share.

Here are some todo's which i am planing as part of its enhancement. It will be a road map for the developers who are interested in doing a open source contribution to this app.

TODO's List:
  1. Support for multiple chats with separate 'chat history' section.(Currently it support only one chat or chat history section (latest requested chat) at a time.)
  2. Giving different sharing options:
  • Sharing to the chatter wall (Currently available).
  • Creating a Case record and sharing chat history as part case comments with some user defined case subject and description.
Any other idea’s from yours side will be greatly appreciated.

For more details related chatter messenger, please follow these pointers:

Wednesday, June 30, 2010

Chatter Messenger on salesforce IdeaExchange

Today i was looking for some chatter messenger related content on salesforce community. I was really very happy to find some good entry there.

There is a entry on ideaExchange for the instant messenger in chatter. There is really a group of peoples who are interested in having some native messenger with in SFDC org.

The other entry was posted on Force.com Discussion Boards

'Chatter Messenger' is available to all who are interested in having a native SFDC messenger with in there org. It is open for your open contribution and support.

I am really looking forward for some open contributions.

Tuesday, June 29, 2010

My CDC Code Share entries

Finally Both my CDC entries Chatter Notifier and Chatter Messenger are now available on salesforce code share One can browse through the code and even contribute if he/she really interested to do show.

One can have look and feel of these apps by installing to there salesforce org. Both are available will install link available on code share home page.

Note: Salesforce org should be chatter enable to allow successful installing of these apps.

Please feel free to contact me in case of any problem related to these apps.

Monday, June 28, 2010

My chatter development challenge entries

I recently participated in salesforce chatter developer challenge (CDC). I submitted two my app for the challenge as 'Chatter Notifier' and 'Chatter Messenger'.

Details of both as follows:

Chatter messenger:

Chatter messenger allow peoples in an organization to chat with each other. They can have one to one communication using chatter messenger without need of any external messenger from within there salesforce org. Finally they have the option of sharing their chat to their chatter wall with a single click ‘share’.

All peoples in an organization are available as chatter messenger contacts. One can select any contact to chat with. If he is online, he can reply you back. If he is offline, he will receive you message when he gets online to chatter messenger app.

Selecting the Chatter Messenger tab login’s that user to chatter messenger app. Your will be then show as online to other Chatter Messenger user’s. One can change their status to either ‘OffLine?’, ‘Do Not Disturb’ or ‘Invisible’ as required by the user.

If a user (contact) is idle for more than 30 minutes, he will logout and his status will be set as offline. He can again get online by changing his status as ‘Online’.

Chatter messenger provide a real time chatting experience like any other messenger. This can help peoples who want to have one to one discussion with each other while working with in the salesforce org. Later one if they feel to share their discussion they can share their chat or discussion on chatter wall.

Chatter Messenger Detail View:





Code for chatter messenger is available on google code.
Chatter Messenger youtube video

Chatter Notifier:

Chatter notifier notifies once's followers with birthday or anniversary dates. Followers can help that person in celebrate by posting a message on his wall or sending him a gift.

One can control his birthday or anniversary notifications to his followers by using the “Notification” setting tab. If a user has disabled/Unchecked his birthday/anniversary notification, his birthday/anniversary will not be notified to his followers.




Code for chatter notifier is available on google code.

Chatter Notifier youtube video

Other Related Links: