+ Start a Discussion
SurenderSurender 

Can we send private feedpost to the user

Hi,

 

 

I have the below code which will send feed post to some particular user. 

 

 

string msg = 'You have automatically swarmed an Opportunity.'+  '\n' +
                       'Opportunity Name : ' + thisOppty.Name+ '\n' + 
                       'Account : ' + thisOppty.Account.Name + '\n' +
                       'Type : ' + thisOppty.Type + '\n' +
                       'Close Date : ' + dateStr + '\n' +
                       'Owner : ' + thisOppty.Owner.Name;
                                
FeedItem swarmNotification = new FeedItem();
swarmNotification.Type = 'LinkPost';
swarmNotification.ParentId = rule.User__c;
swarmNotification.Title = 'Link to Opportunity Record '+thisOppty.Name+' Swarmed';
swarmNotification.Body = msg;
swarmNotification.LinkUrl = URL.getSalesforceBaseUrl().toExternalForm() + '/' + thisOppty.Id;
feedNotifications.add(swarmNotification);

 

But we have problem with the above like the feed post is sent to particular user and the users who are following that user.

 

Can we send private feed post only to that particular user.

 

Share some code snippets for better understanding.

 


ChrisOctagonChrisOctagon

Chatter does not have private feed items, please try using a private message instead.

SurenderSurender

Chris,

 

Can you send me sample code snippet for sending private message..

 

Thanks in advance. 

ChrisOctagonChrisOctagon

Using the Chatter REST API you can send a message from the logged-in user to other users with an HTTP POST to  /chatter/users/me/messages, with a JSON request payload like the following (using content type "application/json"):

 

{
   "body": "Text of the message",
   "recipients": ["userID","userID"],
   "inReplyTo": "messageID"
}

The documentation for this REST endpoint is here: http://www.salesforce.com/us/developer/docs/chatterapi/Content/connect_resources_users_messages_general.htm