ConnectApiHelper icon indicating copy to clipboard operation
ConnectApiHelper copied to clipboard

Added create functions to allow batch processing

Open Henk3000 opened this issue 5 years ago • 1 comments

I was using this code to create a chatter post on a trigger and had a requirement to create a chatter post for each record and therefore I concluded that I needed to bulk insert the feed items.

As the current repo only allowed me to post individual feed items I altered it to "create" instead of directly posting a feed item.

my code now looks like this:

List<ConnectApi.BatchInput> batchInputs = new List<ConnectApi.BatchInput>();
for(Account acc : accs){
  String postMessage = 'test post message for {record:' + acc.Id + '}';
  ConnectApi.FeedItemInput input = ConnectApiHelper.createFeedItemWithRichText(acc.Id, postMessage);
  batchInputs.add(new ConnectApi.BatchInput(input));
}
ConnectApi.ChatterFeeds.postFeedElementBatch(null, batchInputs);

Henk3000 avatar Jun 10 '20 11:06 Henk3000

Thanks for the contribution! Unfortunately we can't verify the commit author(s): Erik <e***@r***.nl>. One possible solution is to add that email to your GitHub account. Alternatively you can change your commits to another email and force push the change. After getting your commits associated with your GitHub account, sign the Salesforce.com Contributor License Agreement and this Pull Request will be revalidated.

salesforce-cla[bot] avatar Jun 10 '20 11:06 salesforce-cla[bot]