您的位置:首页 > 其它

salesforce之chatter

2016-02-26 09:28 453 查看
http://deferloader.blog.uhuru.co.jp/?p=2763

 //投稿処理

    private void doChatter(list<string> chatterMsgList){

        // ChatterGroup名指定

         // ChatterGroup取得

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

        //string targetGroupId = objCollaborationGroup.Id;

        string targetGroupId = this.getGroupId();

        string message ='';

        for (String chatterMsg: chatterMsgList) {

            message +=  chatterMsg;

        }

        // フィードのINSERT

        FeedItem feed = new FeedItem();

        feed.parentId = targetGroupId;

        feed.body = message;

        insert feed;

    }

 public static void toChatter(String chatterMsg) {

        String communityId = null;

        ConnectApi.FeedType feedType = ConnectApi.FeedType.UserProfile;

        String userToMention = UserInfo.getUserId();

        String subjectId = userToMention;

        ConnectApi.MessageBodyInput messageInput = new ConnectApi.MessageBodyInput();

        messageInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();

        // メンション

        ConnectApi.MentionSegmentInput mentionSegment = new ConnectApi.MentionSegmentInput();

        mentionSegment.id = userToMention;

        messageInput.messageSegments.add(mentionSegment);

        // 本文

        ConnectApi.TextSegmentInput textSegment = new ConnectApi.TextSegmentInput();

        textSegment.text = '\r\n';

        messageInput.messageSegments.add(textSegment);

        textSegment = new ConnectApi.TextSegmentInput();

        textSegment.text = chatterMsg;

        messageInput.messageSegments.add(textSegment);

        ConnectApi.FeedItemInput input = new ConnectApi.FeedItemInput();

        input.body = messageInput;

        // Chatter通知

        ConnectApi.FeedItem feedItemRep =

            ConnectApi.ChatterFeeds.postFeedItem(communityId, feedType, subjectId, input, null);

    }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: