tyoshikawa1106のブログ

- Force.com Developer Blog -

SFDC:Chatterグループへ投稿

Apexの処理でChatterグループに投稿することができるか勉強したのでメモ。

Chatterグループの情報は"CollaborationGroup"から取得できました。

フィードの情報は"FeedItem"で取得できるようです。


サンプルです。

// ChatterGroup名指定
String groupName = 'Force.com Developer';

// ChatterGroup取得
CollaborationGroup objCollaborationGroup = [select Id ,Name from CollaborationGroup where Name =: groupName limit 1];

// 投稿内容指定
String chatterMsg = 'Test';

// フィードのINSERT
FeedItem feed = new FeedItem();
feed.parentId = objCollaborationGroup.Id;
feed.body = chatterMsg;
insert feed;