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
Salesforce BeginnerSalesforce Beginner 

How to mention a community user (@-mention) via the Chatter API?

Hi All,

I am trying to understand, how do we mention a community (partner) user using (@-mention) via Chatter API? To give you all a little background of the scenario, we have a custom sharing component, which works pretty much like the standard sharing functionality. There were several considerations to go for custom sharing functionality which ultimately uses share__c object. After sharing the record of a custom__c object, we are using the information from share object to post a chatter message for the shared record. We are using 'ConnectApi.ChatterFeeds.postFeedItem'. In the body of the FeedItem, we are using @-mention user, and the checkbox to receive email notification is checked to receive an email (OOB functionality) when somebody mentions that user.

That being said, on succussful share of the record between two internal users, feed item is posted on the chatter and since we use @-mention in the feeditem body, the email notifications are being sent as we expect - All good here.

Similary when we share the record as an internal user to external user (partner community) user, Share is successful and the insertion of the feed item is successful as well. However, in the body of the feeditem, '@JohnSmith (partner)'  is greyed out. When I hover over the user name, it says, you do not have access to this user. I have tried to understand better, why am I not able to make it work with no luck. Any help to tackle this is greatly appreciated. 


 
NagendraNagendra (Salesforce Developers) 
Hi,

To @-mention a user via the Chatter REST API you must provide a JSON or XML input. The JSON and XML inputs can provide a list of input message segments. Remember to set your "Content-Type" header to "application/json" or "application/xml" to provide this input successfully.
For example the following JSON input includes an @-mention:

 

{

"body": [ 

     { "type":"Text", "text" : "Hello... "},

     {"type":"Mention", "id": "00523423423434"},

     { "type":"Text", "text": " welcome to Salesforce"} ]

}

Hope this helps.

Kindly mark this as solved if the reply was helpful.

Thanks,
Nagendra