Announcements Class

Access information about announcements. An announcement displays in a designated location in the Salesforce UI until 11:59 p.m. on its expiration date, unless it’s deleted or replaced by another announcement.

Namespace

ConnectApi

Usage

Use the ConnectApi.Announcements class to get, update, and delete announcements. Use an announcement to highlight information. Users can discuss, like, and post comments on announcements in the group feed. Group members receive an email notification when you post an announcement, same as for other posts, depending on their selected group email notification frequency. Deleting the feed post deletes the announcement.

This image of Salesforce shows an announcement displayed in yellow. Creating an announcement also creates a feed item with the announcement text, which you can also see in the image.Announcement in the Salesforce UI

Announcements Methods

The following are methods for Announcements. All methods are static.

deleteAnnouncement(communityId, announcementId)

Deletes the specified announcement.

API Version

31.0

Requires Chatter

Yes

Signature

public static void deleteAnnouncement(String communityId, String announcementId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
announcementId
Type: String
An announcement ID, which has a prefix of 0BT.

Return Value

Type: Void

Usage

To get a list of announcements in a group (including announcement IDs), call getAnnouncements(communityId, groupId) or getAnnouncements(communityId, groupId, pageParam, pageSize).

To post an announcement to a group, call postAnnouncement(communityId, groupId, announcement).

getAnnouncement(communityId, announcementId)

Gets the specified announcement.

API Version

31.0

Requires Chatter

Yes

Signature

public static ConnectApi.Announcement getAnnouncement(String communityId, String announcementId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
announcementId
Type: String
An announcement ID, which has a prefix of 0BT.

Return Value

Type: ConnectApi.Announcement

Usage

To get a list of announcements in a group (including announcement IDs), call getAnnouncements(communityId, groupId) or getAnnouncements(communityId, groupId, pageParam, pageSize).

To post an announcement to a group, call postAnnouncement(communityId, groupId, announcement).

updateAnnouncement(communityId, announcementId, expirationDate)

Updates the expiration date of the specified announcement.

API Version

31.0

Requires Chatter

Yes

Signature

public static ConnectApi.Announcement updateAnnouncement(String communityId, String announcementId, Datetime expirationDate)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
announcementId
Type: String
An announcement ID, which has a prefix of 0BT.
expirationDate
Type: Datetime
The Salesforce UI displays an announcement until 11:59 p.m. on this date unless another announcement is posted first. The Salesforce UI ignores the time value in the expirationDate. However, you can use the time value to create your own display logic in your own UI.

Return Value

Type: ConnectApi.Announcement

Usage

To get a list of announcements in a group (including announcement IDs), call getAnnouncements(communityId, groupId) or getAnnouncements(communityId, groupId, pageParam, pageSize).

To post an announcement to a group, call postAnnouncement(communityId, groupId, announcement).