Newer Version Available
Announcements Class
Namespace
Usage
Use the ConnectApi.Announcements class to get, create, update, and delete announcements. Use an announcement to highlight information. Users can discuss, like, and post comments on announcements. Deleting the feed post deletes the announcement.
This image shows an announcement displayed in a group. Creating an announcement also creates a
feed item with the announcement text.
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.
Announcements Methods
The following are methods for Announcements. All methods are static.
deleteAnnouncement(communityId, announcementId)
API Version
31.0
Requires Chatter
Yes
Signature
public static void deleteAnnouncement(String communityId, String announcementId)
Parameters
Return Value
Type: Void
Usage
To get a list of announcements in a group, call getAnnouncements(communityId, parentId) or getAnnouncements(communityId, parentId, pageParam, pageSize).
To post an announcement to a group, call postAnnouncement(communityId, announcement) .
getAnnouncement(communityId, announcementId)
API Version
31.0
Requires Chatter
Yes
Signature
public static ConnectApi.Announcement getAnnouncement(String communityId, String announcementId)
Parameters
Return Value
Type: ConnectApi.Announcement
Usage
To get a list of announcements in a group, call getAnnouncements(communityId, parentId) or getAnnouncements(communityId, parentId, pageParam, pageSize).
To post an announcement to a group, call postAnnouncement(communityId, announcement) .
getAnnouncements(communityId, parentId)
API Version
36.0
Available to Guest Users
38.0
Requires Chatter
Yes
Signature
public static ConnectApi.AnnouncementPage getAnnouncements(String communityId, String parentId)
Parameters
Return Value
getAnnouncements(communityId, parentId, pageParam, pageSize)
API Version
36.0
Available to Guest Users
38.0
Requires Chatter
Yes
Signature
public static ConnectApi.AnnouncementPage getAnnouncements(String communityId, String parentId, Integer pageParam, Integer pageSize)
Parameters
- communityId
- Type: String
- Use either the ID for a community, internal, or null.
- parentId
- Type: String
- ID of the parent entity for the announcement, that is, a group ID when the announcement appears in a group.
- pageParam
- Type: Integer
- Specifies the number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.
- pageSize
- Type: Integer
- Specifies the number of announcements per page.
Return Value
postAnnouncement(communityId, announcement)
API Version
36.0
Requires Chatter
Yes
Signature
public static ConnectApi.Announcement postAnnouncement(String communityId, ConnectApi.AnnouncementInput announcement)
Parameters
- communityId
- Type: String
- Use either the ID for a community, internal, or null.
- announcement
- Type: ConnectApi.AnnouncementInput
- A ConnectApi.AnnouncementInput object.
Return Value
Type: ConnectApi.Announcement
updateAnnouncement(communityId, announcementId, expirationDate)
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, call getAnnouncements(communityId, parentId) or getAnnouncements(communityId, parentId, pageParam, pageSize).
To post an announcement to a group, call postAnnouncement(communityId, announcement) .