I am trying to insert feeditems with mentions on a case using SOAP API.

Example - "This case was updated by @John Doe" where John Doe is a user in Salesforce.

How do I make this happen?

I have tried the following

FeedItem fi = new FeedItem();

fi.Body = '@[John Doe](user:*Salesforce User ID*)';

fi.ParentId =  *Case ID*;

fi.Type = 'TextPost';

It doesn't appear to be possible to do anything other than a plain text FeedItem with the SOAP API.

I tried the following directly POSTed to the SOAP API.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:partner.soap.sforce.com" xmlns:urn1="urn:sobject.partner.soap.sforce.com">
         <!--Zero or more repetitions:-->
            <!--Zero or more repetitions:-->
            <!--You may enter ANY elements at this point-->
            <urn1:Body>&lt;p&gt;Test Post 4 with mention of @Daniel Ballinger &lt;/p&gt;</urn1:Body>

That created a FeedItem record that was identical to on I created directly in the UI with an active Mention of myself. Or at least, identical in how the SOAP Partner API sees the FeedItem records.

enter image description here

I suspect you will need to use the REST based Chatter API to define a richer Feed Item Body with message segments for mentions.

There is an idea - Add @mention to Chatter FeedItem body via Apex Code or AJAX Toolkit, but that appears to have mostly focused on the Apex Chatter integration.

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.