You need to sign in to do that
Don't have an account?
How to create Announcement in Chatter via Apex
Hello!
Could you help to solve this ussue?
I cann't create an anouncement via Apex. I used this code, but it doesn't work properly.
List<ConnectApi.MessageSegmentInput> test = new List<ConnectApi.MessageSegmentInput>();
test.add('test');
ConnectApi.MessageBodyInput testBody = new ConnectApi.MessageBodyInput();
testBody = test;
ConnectApi.AnnouncementInput testGroup = new ConnectApi.AnnouncementInput();
testGroup.body = testBody;
testGroup.expirationDate = Date.today() + 2;
testGroup.parentId = '0F95i000000xSYpCAM';
ConnectApi.Announcement.postAnnouncement(null, testGroup);
Please try this code
Please review the code and understand.
Let me know if this works and help.
Chatter Announcements are nothing but FeedItem records.
Thanks!!
Thank you! You set me on the right path)
FeedItem objPost = new FeedItem();
objPost.ParentId = '0F95i000000xSYpCAM'; // Id group or others
objPost.Body = 'Hello there from APEX';
objPost.Type = 'AdvancedTextPost';
insert objPost;
Announcement ann = new Announcement();
ann.FeedItemId = objPost.Id;
ann.ExpirationDate = Datetime.newInstance(2022, 9, 1);
insert ann;