Recommendations Class

Access information about recommendations and reject recommendations. Also create, delete, get, and update recommendation audiences, recommendation definitions, and scheduled recommendations.

Namespace

ConnectApi

Recommendations Methods

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

createRecommendationAudience(communityId, recommendationAudience)

Create an audience for a recommendation.

API Version

35.0

Requires Chatter

No

Signature

public static ConnectApi.RecommendationAudience createRecommendationAudience(String communityId, ConnectApi.RecommendationAudienceInput recommendationAudience)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
recommendationAudience
Type: ConnectApi.RecommendationAudienceInput
A ConnectApi.RecommendationAudienceInput object.

Return Value

Type: ConnectApi.​RecommendationAudience

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

createRecommendationAudience(communityId, name)

Create an audience for a recommendation.

API Version

35.0

Requires Chatter

No

Signature

public static ConnectApi.RecommendationAudience createRecommendationAudience(String communityId, String name)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
name
Type: String
The name of the audience.

Return Value

Type: ConnectApi.​RecommendationAudience

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

createRecommendationDefinition(communityId, recommendationDefinition)

Create a recommendation definition.

API Version

35.0

Requires Chatter

No

Signature

public static ConnectApi.RecommendationDefinition createRecommendationDefinition(String communityId, ConnectApi.RecommendationDefinitionInput recommendationDefinition)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
recommendationDefinition
Type: ConnectApi.RecommendationDefinitionInput
A ConnectApi.RecommendationDefinitionInput object.

Return Value

Type: ConnectApi.RecommendationDefinition

Usage

Recommendation definitions allow you to create custom recommendations that appear in communities, encouraging users to watch videos, take training and more.

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

These recommendations appear by default on the Customer Service template. Specifically, on the community home and question detail pages and in the feed in communities in the Salesforce mobile web. They also appear anywhere community managers add recommendations using Community Builder in communities using the Summer ’15 or later version of the Customer Service template.

createRecommendationDefinition(communityId, name, title, actionUrl, actionUrlName, explanation)

Create a recommendation definition with the specified parameters.

API Version

35.0

Requires Chatter

No

Signature

public static ConnectApi.RecommendationDefinition createRecommendationDefinition(String communityId, String name, String title, String actionUrl, String actionUrlName, String explanation)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
name
Type: String
The name of the recommendation definition. The name is displayed in Setup.
title
Type: String
The title of the recommendation definition.
actionUrl
Type: String
The URL for acting on the recommendation, for example, the URL to join a group.
actionUrlName
Type: String
The text label for the action URL in the user interface, for example, “Launch.”
explanation
Type: String
The explanation, or body, of the recommendation.

Return Value

Type: ConnectApi.RecommendationDefinition

Usage

Recommendation definitions allow you to create custom recommendations that appear in communities, encouraging users to watch videos, take training and more.

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

These recommendations appear by default on the Customer Service template. Specifically, on the community home and question detail pages and in the feed in communities in the Salesforce mobile web. They also appear anywhere community managers add recommendations using Community Builder in communities using the Summer ’15 or later version of the Customer Service template.

createScheduledRecommendation(communityId, scheduledRecommendation)

Create a scheduled recommendation.

API Version

35.0

Requires Chatter

No

Signature

public static ConnectApi.ScheduledRecommendation createScheduledRecommendation(String communityId, ConnectApi.ScheduledRecommendationInput scheduledRecommendation)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
scheduledRecommendation
Type: ConnectApi.ScheduledRecommendationInput
A ConnectApi.ScheduledRecommendationInput object.

Return Value

Type: ConnectApi.ScheduledRecommendation

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

createScheduledRecommendation(communityId, recommendationDefinitionId, rank, enabled, recommendationAudienceId)

Create a scheduled recommendation with the specified parameters.

API Version

Requires Chatter

No

Signature

public static ConnectApi.ScheduledRecommendation createScheduledRecommendation(String communityId, String recommendationDefinitionId, Integer rank, Boolean enabled, String recommendationAudienceId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
recommendationDefinitionId
Type: String
ID of the recommendation definition.
rank
Type: Integer
Relative rank of the scheduled recommendation indicated by ascending whole numbers starting with 1.

Setting the rank is comparable to an insertion into an ordered list. The scheduled recommendation is inserted into the position specified by the rank. The rank of all the scheduled recommendations after it is pushed down. See Ranking scheduled recommendations example.

If the specified rank is larger than the size of the list, the scheduled recommendation is put at the end of the list. The rank of the scheduled recommendation is the size of the list, instead of the one specified.

If a rank is not specified, the scheduled recommendation is put at the end of the list.

enabled
Type: Boolean
Indicates whether scheduling is enabled. If true, the recommendation is enabled and appears in communities. If false, recommendations in feeds in the Salesforce mobile web aren’t removed, but no new recommendations appear. In Customer Service and Partner Central communities, disabled recommendations no longer appear.
recommendationAudienceId
Type: String
ID of the recommendation definition that this scheduled recommendation schedules.

Return Value

Type: ConnectApi.ScheduledRecommendation

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

Ranking scheduled recommendations example

If you have these scheduled recommendations:

Scheduled Recommendations Rank
ScheduledRecommendationA 1
ScheduledRecommendationB 2
ScheduledRecommendationC 3

And you include this information in the Scheduled Recommendation Input:

Scheduled Recommendation Rank
ScheduledRecommendationD 2

The result is:

Scheduled Recommendation Rank
ScheduledRecommendationA 1
ScheduledRecommendationD 2
ScheduledRecommendationB 3
ScheduledRecommendationC 4

createScheduledRecommendation(communityId, recommendationDefinitionId, rank, enabled, recommendationAudienceId, channel)

Create a scheduled recommendation with the specified parameters.

API Version

36.0

Requires Chatter

No

Signature

public static ConnectApi.ScheduledRecommendation createScheduledRecommendation(String communityId, String recommendationDefinitionId, Integer rank, Boolean enabled, String recommendationAudienceId, ConnectApi.RecommendationChannel channel)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
recommendationDefinitionId
Type: String
ID of the recommendation definition.
rank
Type: Integer
Relative rank of the scheduled recommendation indicated by ascending whole numbers starting with 1.

Setting the rank is comparable to an insertion into an ordered list. The scheduled recommendation is inserted into the position specified by the rank. The rank of all the scheduled recommendations after it is pushed down. See Ranking scheduled recommendations example.

If the specified rank is larger than the size of the list, the scheduled recommendation is put at the end of the list. The rank of the scheduled recommendation is the size of the list, instead of the one specified.

If a rank is not specified, the scheduled recommendation is put at the end of the list.

enabled
Type: Boolean
Indicates whether scheduling is enabled. If true, the recommendation is enabled and appears in communities. If false, recommendations in feeds in the Salesforce mobile web aren’t removed, but no new recommendations appear. In Customer Service and Partner Central communities, disabled recommendations no longer appear.
recommendationAudienceId
Type: String
ID of the recommendation definition that this scheduled recommendation schedules.
channel
Type: ConnectApi.RecommendationChannel
A way to tie recommendations together, for example, to display recommendations in specific places in the UI or to show recommendations based on time of day or geographic locations. Values are:
  • CustomChannel1Custom recommendation channel. Not used by default. Work with your community manager to define custom channels. For example, community managers can use Community Builder to determine where recommendations appear.
  • CustomChannel2—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • CustomChannel3—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • CustomChannel4—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • CustomChannel5—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • DefaultChannel—Default recommendation channel. Recommendations appear by default on the Home and Question Detail pages of Customer Service and Partner Central communities. They also appear in the feed in communities in the Salesforce mobile web and anywhere community managers add recommendations using Community Builder.
Use these channel values; you can’t rename or create other channels.

Return Value

Type: ConnectApi.ScheduledRecommendation

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

Ranking scheduled recommendations example

If you have these scheduled recommendations:

Scheduled Recommendations Rank
ScheduledRecommendationA 1
ScheduledRecommendationB 2
ScheduledRecommendationC 3

And you include this information in the Scheduled Recommendation Input:

Scheduled Recommendation Rank
ScheduledRecommendationD 2

The result is:

Scheduled Recommendation Rank
ScheduledRecommendationA 1
ScheduledRecommendationD 2
ScheduledRecommendationB 3
ScheduledRecommendationC 4

deleteRecommendationAudience(communityId, recommendationAudienceId)

Delete a recommendation audience.

API Version

35.0

Requires Chatter

No

Signature

public static Void deleteRecommendationAudience(String communityId, String recommendationAudienceId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
recommendationAudienceId
Type: String
ID of the recommendation audience.

Return Value

Type: Void

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

deleteRecommendationDefinition(communityId, recommendationDefinitionId)

Delete a recommendation definition.

API Version

35.0

Requires Chatter

No

Signature

public static Void deleteRecommendationDefinition(String communityId, String recommendationDefinitionId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
recommendationDefinitionId
Type: String
ID of the recommendation definition.

Return Value

Type: Void

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

deleteRecommendationDefinitionPhoto(communityId, recommendationDefinitionId)

Delete a recommendation definition photo.

API Version

35.0

Requires Chatter

Yes

Signature

public static Void deleteRecommendationDefinitionPhoto(String communityId, String recommendationDefinitionId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
recommendationDefinitionId
Type: String
ID of the recommendation definition.

Return Value

Type: Void

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

deleteScheduledRecommendation(communityId, scheduledRecommendationId, deleteDefinitionIfLast)

Delete a scheduled recommendation.

API Version

35.0

Requires Chatter

No

Signature

public static Void deleteScheduledRecommendation(String communityId, String scheduledRecommendationId, Boolean deleteDefinitionIfLast)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
scheduledRecommendationId
Type: String
ID of the scheduled recommendation.
deleteDefinitionIfLast
Type: Boolean
If true and if this is the last scheduled recommendation of a recommendation definition, deletes the recommendation definition. Default is false.

Return Value

Type: Void

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

Deleting a scheduled recommendation is comparable to a deletion in an ordered list. All scheduled recommendations after the deleted scheduled recommendation receive a new, higher rank automatically.

getRecommendationAudience(communityId, recommendationAudienceId)

Get information about a recommendation audience.

API Version

35.0

Requires Chatter

No

Signature

public static ConnectApi.RecommendationAudience getRecommendationAudience(String communityId, String recommendationAudienceId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
recommendationAudienceId
Type: String
ID of the recommendation audience.

Return Value

Type: ConnectApi.​RecommendationAudience

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

getRecommendationAudienceMembership(communityId, recommendationAudienceId)

Get the members of a recommendation audience.

API Version

35.0

Requires Chatter

No

Signature

public static ConnectApi.UserReferencePage getRecommendationAudienceMembership(String communityId, String recommendationAudienceId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
recommendationAudienceId
Type: String
ID of the recommendation audience.

Return Value

Type: ConnectApi.​UserReferencePage

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

getRecommendationAudienceMembership(communityId, recommendationAudienceId, pageParam, pageSize)

Get a page of recommendation audience members.

API Version

35.0

Requires Chatter

No

Signature

public static ConnectApi.UserReferencePage getRecommendationAudienceMembership(String communityId, String recommendationAudienceId, Integer pageParam, Integer pageSize)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
recommendationAudienceId
Type: String
ID of the recommendation audience.
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 members per page.

Return Value

Type: ConnectApi.​UserReferencePage

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

getRecommendationAudiences(communityId)

Get recommendation audiences.

API Version

35.0

Requires Chatter

No

Signature

public static ConnectApi.RecommendationAudiencePage getRecommendationAudiences(String communityId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.

Return Value

Type: ConnectApi.RecommendationAudiencePage

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

getRecommendationAudiences(communityId, pageParam, pageSize)

Get a page of recommendation audiences.

API Version

35.0

Requires Chatter

No

Signature

public static ConnectApi.RecommendationAudiencePage getRecommendationAudiences(String communityId, Integer pageParam, Integer pageSize)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
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 audiences per page.

Return Value

Type: ConnectApi.RecommendationAudiencePage

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

getRecommendationDefinition(communityId, recommendationDefinitionId)

Get a recommendation definition.

API Version

35.0

Requires Chatter

No

Signature

public static ConnectApi.RecommendationDefinition getRecommendationDefinition(String communityId, String recommendationDefinitionId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
recommendationDefinitionId
Type: String
ID of the recommendation definition.

Return Value

Type: ConnectApi.RecommendationDefinition

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

getRecommendationDefinitionPhoto(communityId, recommendationDefinitionId)

Get a recommendation definition photo.

API Version

35.0

Requires Chatter

Yes

Signature

public static ConnectApi.Photo getRecommendationDefinitionPhoto(String communityId, String recommendationDefinitionId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
recommendationDefinitionId
Type: String
ID of the recommendation definition.

Return Value

Type: ConnectApi.Photo

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

getRecommendationDefinitions(communityId)

Get recommendation definitions.

API Version

35.0

Requires Chatter

No

Signature

public static ConnectApi.RecommendationDefinitionPage getRecommendationDefinitions(String communityId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.

Return Value

Type: ConnectApi.RecommendationDefinitionPage

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

getRecommendationForUser(communityId, userId, action, objectId)

Returns the recommendation for the context user for the specified action and object ID.

API Version

33.0

Requires Chatter

Yes

Signature

public static ConnectApi.RecommendationCollection getRecommendationForUser(String communityId, String userId, ConnectApi.RecommendationActionType action, String objectId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
userId
Type: String
The ID for the context user or the keyword me.
action
Type: ConnectApi.​RecommendationActionType
Specifies the action to take on a recommendation.
  • follow—Follow a file, record, topic, or user.
  • join—Join a group.
  • view—View a file, group, article, record, user, custom, or static recommendation.
objectId
Type: String
Specifies the object to take action on.
  • If action is follow, objectId is a user ID, file ID, record ID, or topic ID (version 36.0 and later).
  • If action is join, objectId is a group ID.
  • If action is view, objectId is a user ID, file ID, group ID, record ID, custom recommendation ID (version 34.0 and later), the enum Today for static recommendations (version 35.0 and later), or an article ID (version 37.0 and later).

Return Value

Type: ConnectApi.RecommendationCollection

Usage

To test code that uses this method, use the matching set test method (prefix the method name with setTest). Use the set test method with the same parameters or the code throws an exception.

getRecommendationsForUser(communityId, userId, contextAction, contextObjectId, maxResults)

Returns the user, group, file, record, custom, and static recommendations for the context user.

API Version

Requires Chatter

Yes

Signature

public static ConnectApi.RecommendationCollection getRecommendationsForUser(String communityId, String userId, ConnectApi.RecommendationActionType contextAction, String contextObjectId, Integer maxResults)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
userId
Type: String
The ID for the context user or the keyword me.
contextAction
Type: ConnectApi.​RecommendationActionType
Action that the context user just performed. Supported values are:
  • follow
  • view
Use contextAction and contextObjectId together to get new recommendations based on the action just performed. If you don’t want recommendations based on a recent action, specify null.
contextObjectId
Type: String
ID of the object that the context user just performed an action on.
  • If contextAction is follow, contextObjectId is a user ID, file ID, or record ID.
  • If contextAction is view, contextObjectId is a user ID, file ID, group ID, or record ID.
Use contextAction and contextObjectId together to get new recommendations based on the action just performed. If you don’t want recommendations based on a recent action, specify null.
maxResults
Type: Integer
Maximum number of recommendation results; default is 10. Values must be from 1 to 99.

Return Value

Type: ConnectApi.RecommendationCollection

Usage

If you want to get recommendations based on a recent action performed, such as following a user, use contextAction and contextObjectId together. For example, if you just followed Pam, you specify follow for contextAction and Pam’s user ID for contextObjectId.

This method only recommends users who are followed by people who follow Pam. In this example, John follows Pam so the method returns a recommendation for you to follow Suzanne since John also follows Suzanne.Your new recommendation to follow Suzanne.

To test code that uses this method, use the matching set test method (prefix the method name with setTest). Use the set test method with the same parameters or the code throws an exception.

getRecommendationsForUser(communityId, userId, contextAction, contextObjectId, channel, maxResults)

Returns the user, group, file, article, record, topic, custom, and static recommendations for the context user.

API Version

36.0

Available to Guest Users

38.0
Note

Note

Only article and file recommendations are available to guest users.

Requires Chatter

Yes

Signature

public static ConnectApi.RecommendationCollection getRecommendationsForUser(String communityId, String userId, ConnectApi.RecommendationActionType contextAction, String contextObjectId, ConnectApi.RecommendationChannel channel, Integer maxResults)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
userId
Type: String
The ID for the context user or the keyword me.
contextAction
Type: ConnectApi.​RecommendationActionType
Action that the context user just performed. Supported values are:
  • follow
  • view
Use contextAction and contextObjectId together to get new recommendations based on the action just performed. If you don’t want recommendations based on a recent action, specify null.
contextObjectId
Type: String
ID of the object that the context user just performed an action on.
  • If contextAction is follow, contextObjectId is a user ID, file ID, record ID, or topic ID.
  • If contextAction is view, contextObjectId is a user ID, file ID, group ID, record ID, or article ID (version 37.0 and later).
Use contextAction and contextObjectId together to get new recommendations based on the action just performed. If you don’t want recommendations based on a recent action, specify null.
channel
Type: ConnectApi.RecommendationChannel
A way to tie recommendations together, for example, to display recommendations in specific places in the UI or to show recommendations based on time of day or geographic locations. Values are:
  • CustomChannel1Custom recommendation channel. Not used by default. Work with your community manager to define custom channels. For example, community managers can use Community Builder to determine where recommendations appear.
  • CustomChannel2—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • CustomChannel3—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • CustomChannel4—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • CustomChannel5—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • DefaultChannel—Default recommendation channel. Recommendations appear by default on the Home and Question Detail pages of Customer Service and Partner Central communities. They also appear in the feed in communities in the Salesforce mobile web and anywhere community managers add recommendations using Community Builder.
maxResults
Type: Integer
Maximum number of recommendation results; default is 10. Values must be from 1 to 99.

Return Value

Type: ConnectApi.RecommendationCollection

Usage

If you want to get recommendations based on a recent action performed, such as following a user, use contextAction and contextObjectId together. For example, if you just followed Pam, you specify follow for contextAction and Pam’s user ID for contextObjectId.

This method only recommends users who are followed by people who follow Pam. In this example, John follows Pam so the method returns a recommendation for you to follow Suzanne since John also follows Suzanne.Your new recommendation to follow Suzanne.

To test code that uses this method, use the matching set test method (prefix the method name with setTest). Use the set test method with the same parameters or the code throws an exception.

getRecommendationsForUser(communityId, userId, action, contextAction, contextObjectId, maxResults)

Returns the recommendations for the context user for the specified action.

API Version

Requires Chatter

Yes

Signature

public static ConnectApi.RecommendationCollection getRecommendationsForUser(String communityId, String userId, ConnectApi.RecommendationActionType action, ConnectApi.RecommendationActionType contextAction, String contextObjectId, Integer maxResults)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
userId
Type: String
The ID for the context user or the keyword me.
action
Type: ConnectApi.​RecommendationActionType
Specifies the action to take on a recommendation.
  • follow—Follow a file, record, topic, or user.
  • join—Join a group.
  • view—View a file, group, article, record, user, custom, or static recommendation.
contextAction
Type: ConnectApi.​RecommendationActionType
Action that the context user just performed. Supported values are:
  • follow
  • view
Use contextAction and contextObjectId together to get new recommendations based on the action just performed. If you don’t want recommendations based on a recent action, specify null.
contextObjectId
Type: String
ID of the object that the context user just performed an action on.
  • If contextAction is follow, contextObjectId is a user ID, file ID, or record ID.
  • If contextAction is view, contextObjectId is a user ID, file ID, group ID, or record ID.
Use contextAction and contextObjectId together to get new recommendations based on the action just performed. If you don’t want recommendations based on a recent action, specify null.
maxResults
Type: Integer
Maximum number of recommendation results; default is 10. Values must be from 1 to 99.

Return Value

Type: ConnectApi.RecommendationCollection

Usage

If you want to get recommendations based on a recent action performed, such as following a user, use contextAction and contextObjectId together. For example, if you just followed Pam, you specify follow for contextAction and Pam’s user ID for contextObjectId.

This method only recommends users who are followed by people who follow Pam. In this example, John follows Pam so the method returns a recommendation for you to follow Suzanne since John also follows Suzanne.Your new recommendation to follow Suzanne.

To test code that uses this method, use the matching set test method (prefix the method name with setTest). Use the set test method with the same parameters or the code throws an exception.

getRecommendationsForUser(communityId, userId, action, contextAction, contextObjectId, channel, maxResults)

Returns the recommendations for the context user for the specified action.

API Version

36.0

Available to Guest Users

38.0
Note

Note

Only article and file recommendations are available to guest users.

Requires Chatter

Yes

Signature

public static ConnectApi.RecommendationCollection getRecommendationsForUser(String communityId, String userId, ConnectApi.RecommendationActionType action, ConnectApi.RecommendationActionType contextAction, String contextObjectId, ConnectApi.RecommendationChannel channel, Integer maxResults)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
userId
Type: String
The ID for the context user or the keyword me.
action
Type: ConnectApi.​RecommendationActionType
Specifies the action to take on a recommendation.
  • follow—Follow a file, record, topic, or user.
  • join—Join a group.
  • view—View a file, group, article, record, user, custom, or static recommendation.
contextAction
Type: ConnectApi.​RecommendationActionType
Action that the context user just performed. Supported values are:
  • follow
  • view
Use contextAction and contextObjectId together to get new recommendations based on the action just performed. If you don’t want recommendations based on a recent action, specify null.
contextObjectId
Type: String
ID of the object that the context user just performed an action on.
  • If contextAction is follow, contextObjectId is a user ID, file ID, record ID, or topic ID.
  • If contextAction is view, contextObjectId is a user ID, file ID, group ID, record ID, or article ID (version 37.0 and later).
Use contextAction and contextObjectId together to get new recommendations based on the action just performed. If you don’t want recommendations based on a recent action, specify null.
channel
Type: ConnectApi.RecommendationChannel
A way to tie recommendations together, for example, to display recommendations in specific places in the UI or to show recommendations based on time of day or geographic locations. Values are:
  • CustomChannel1Custom recommendation channel. Not used by default. Work with your community manager to define custom channels. For example, community managers can use Community Builder to determine where recommendations appear.
  • CustomChannel2—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • CustomChannel3—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • CustomChannel4—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • CustomChannel5—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • DefaultChannel—Default recommendation channel. Recommendations appear by default on the Home and Question Detail pages of Customer Service and Partner Central communities. They also appear in the feed in communities in the Salesforce mobile web and anywhere community managers add recommendations using Community Builder.
maxResults
Type: Integer
Maximum number of recommendation results; default is 10. Values must be from 1 to 99.

Return Value

Type: ConnectApi.RecommendationCollection

Usage

If you want to get recommendations based on a recent action performed, such as following a user, use contextAction and contextObjectId together. For example, if you just followed Pam, you specify follow for contextAction and Pam’s user ID for contextObjectId.

This method only recommends users who are followed by people who follow Pam. In this example, John follows Pam so the method returns a recommendation for you to follow Suzanne since John also follows Suzanne.Your new recommendation to follow Suzanne.

To test code that uses this method, use the matching set test method (prefix the method name with setTest). Use the set test method with the same parameters or the code throws an exception.

getRecommendationsForUser(communityId, userId, action, objectCategory, contextAction, contextObjectId, maxResults)

Returns the recommendations for the context user for the specified action and object category.

API Version

Requires Chatter

Yes

Signature

public static ConnectApi.RecommendationCollection getRecommendationsForUser(String communityId, String userId, ConnectApi.RecommendationActionType action, String objectCategory, ConnectApi.RecommendationActionType contextAction, String contextObjectId, Integer maxResults)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
userId
Type: String
The ID for the context user or the keyword me.
action
Type: ConnectApi.​RecommendationActionType
Specifies the action to take on a recommendation.
  • follow—Follow a file, record, topic, or user.
  • join—Join a group.
  • view—View a file, group, article, record, user, custom, or static recommendation.
objectCategory
Type: String
  • If action is follow, objectCategory is users, files, or records.
  • If action is join, objectCategory is groups.
  • If action is view, objectCategory is users, files, groups, records, custom, or apps.
You can also specify a key prefix, the first three characters of the object ID, as the objectCategory. Valid values are:
  • If action is follow, objectCategory is 005 (users), 069 (files), or 001 (accounts), for example.
  • If action is join, objectCategory is 0F9 (groups).
  • If action is view, objectCategory is 005 (users), 069 (files), 0F9 (groups), 0RD (custom recommendations), T (static recommendations), or 001 (accounts), for example.
contextAction
Type: ConnectApi.​RecommendationActionType
Action that the context user just performed. Supported values are:
  • follow
  • view
Use contextAction and contextObjectId together to get new recommendations based on the action just performed. If you don’t want recommendations based on a recent action, specify null.
contextObjectId
Type: String
ID of the object that the context user just performed an action on.
  • If contextAction is follow, contextObjectId is a user ID, file ID, or record ID.
  • If contextAction is view, contextObjectId is a user ID, file ID, group ID, or record ID.
Use contextAction and contextObjectId together to get new recommendations based on the action just performed. If you don’t want recommendations based on a recent action, specify null.
maxResults
Type: Integer
Maximum number of recommendation results; default is 10. Values must be from 1 to 99.

Return Value

Type: ConnectApi.RecommendationCollection

Usage

If you want to get recommendations based on a recent action performed, such as following a user, use contextAction and contextObjectId together. For example, if you just followed Pam, you specify follow for contextAction and Pam’s user ID for contextObjectId.

This method only recommends users who are followed by people who follow Pam. In this example, John follows Pam so the method returns a recommendation for you to follow Suzanne since John also follows Suzanne.Your new recommendation to follow Suzanne.

To test code that uses this method, use the matching set test method (prefix the method name with setTest). Use the set test method with the same parameters or the code throws an exception.

getRecommendationsForUser(communityId, userId, action, objectCategory, contextAction, contextObjectId, channel, maxResults)

Returns the recommendations for the context user for the specified action and object category.

API Version

36.0

Available to Guest Users

38.0
Note

Note

Only article and file recommendations are available to guest users.

Requires Chatter

Yes

Signature

public static ConnectApi.RecommendationCollection getRecommendationsForUser(String communityId, String userId, ConnectApi.RecommendationActionType action, String objectCategory, ConnectApi.RecommendationActionType contextAction, String contextObjectId, ConnectApi.RecommendationChannel channel, Integer maxResults)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
userId
Type: String
The ID for the context user or the keyword me.
action
Type: ConnectApi.​RecommendationActionType
Specifies the action to take on a recommendation.
  • follow—Follow a file, record, topic, or user.
  • join—Join a group.
  • view—View a file, group, article, record, user, custom, or static recommendation.
objectCategory
Type: String
  • If action is follow, objectCategory is users, files, topics, or records.
  • If action is join, objectCategory is groups.
  • If action is view, objectCategory is users, files, groups, records, custom, apps, or articles (version 37.0 and later).
You can also specify a key prefix, the first three characters of the object ID, as the objectCategory. Valid values are:
  • If action is follow, objectCategory is 005 (users), 069 (files), 0TO (topics), or 001 (accounts), for example.
  • If action is join, objectCategory is 0F9 (groups).
  • If action is view, objectCategory is 005 (users), 069 (files), 0F9 (groups), 0RD (custom recommendations), T (static recommendations), 001 (accounts), or kA0 (articles), for example, (version 370 and later).
contextAction
Type: ConnectApi.​RecommendationActionType
Action that the context user just performed. Supported values are:
  • follow
  • view
Use contextAction and contextObjectId together to get new recommendations based on the action just performed. If you don’t want recommendations based on a recent action, specify null.
contextObjectId
Type: String
ID of the object that the context user just performed an action on.
  • If contextAction is follow, contextObjectId is a user ID, file ID, record ID, or topic ID.
  • If contextAction is view, contextObjectId is a user ID, file ID, group ID, record ID, or article ID (version 37.0 and later).
Use contextAction and contextObjectId together to get new recommendations based on the action just performed. If you don’t want recommendations based on a recent action, specify null.
channel
Type: ConnectApi.RecommendationChannel
A way to tie recommendations together, for example, to display recommendations in specific places in the UI or to show recommendations based on time of day or geographic locations. Values are:
  • CustomChannel1Custom recommendation channel. Not used by default. Work with your community manager to define custom channels. For example, community managers can use Community Builder to determine where recommendations appear.
  • CustomChannel2—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • CustomChannel3—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • CustomChannel4—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • CustomChannel5—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • DefaultChannel—Default recommendation channel. Recommendations appear by default on the Home and Question Detail pages of Customer Service and Partner Central communities. They also appear in the feed in communities in the Salesforce mobile web and anywhere community managers add recommendations using Community Builder.
maxResults
Type: Integer
Maximum number of recommendation results; default is 10. Values must be from 1 to 99.

Return Value

Type: ConnectApi.RecommendationCollection

Usage

If you want to get recommendations based on a recent action performed, such as following a user, use contextAction and contextObjectId together. For example, if you just followed Pam, you specify follow for contextAction and Pam’s user ID for contextObjectId.

This method only recommends users who are followed by people who follow Pam. In this example, John follows Pam so the method returns a recommendation for you to follow Suzanne since John also follows Suzanne.Your new recommendation to follow Suzanne.

To test code that uses this method, use the matching set test method (prefix the method name with setTest). Use the set test method with the same parameters or the code throws an exception.

getScheduledRecommendation(communityId, scheduledRecommendationId)

Get a scheduled recommendation.

API Version

35.0

Requires Chatter

No

Signature

public static ConnectApi.ScheduledRecommendation getScheduledRecommendation(String communityId, String scheduledRecommendationId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
scheduledRecommendationId
Type: String
ID of the scheduled recommendation.

Return Value

Type: ConnectApi.ScheduledRecommendation

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

getScheduledRecommendations(communityId)

Get scheduled recommendations.

API Version

35.0 only
Important

Important

In version 36.0 and later, use getScheduledRecommendations(communityId, channel).

Requires Chatter

No

Signature

public static ConnectApi.ScheduledRecommendationPage getScheduledRecommendations(String communityId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.

Return Value

Type: ConnectApi.ScheduledRecommendationPage

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

getScheduledRecommendations(communityId, channel)

Get scheduled recommendations.

API Version

36.0

Requires Chatter

No

Signature

public static ConnectApi.ScheduledRecommendationPage getScheduledRecommendations(String communityId, ConnectApi.RecommendationChannel channel)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
channel
Type: ConnectApi.RecommendationChannel
A way to tie recommendations together, for example, to display recommendations in specific places in the UI or to show recommendations based on time of day or geographic locations. Values are:
  • CustomChannel1Custom recommendation channel. Not used by default. Work with your community manager to define custom channels. For example, community managers can use Community Builder to determine where recommendations appear.
  • CustomChannel2—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • CustomChannel3—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • CustomChannel4—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • CustomChannel5—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • DefaultChannel—Default recommendation channel. Recommendations appear by default on the Home and Question Detail pages of Customer Service and Partner Central communities. They also appear in the feed in communities in the Salesforce mobile web and anywhere community managers add recommendations using Community Builder.

Return Value

Type: ConnectApi.ScheduledRecommendationPage

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

rejectRecommendationForUser(communityId, userId, action, objectId)

Rejects the recommendation for the context user for the specified action and object ID.

API Version

33.0

Requires Chatter

Yes

Signature

public static rejectRecommendationForUser(String communityId, String userId, ConnectApi.RecommendationActionType action, String objectId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
userId
Type: String
The ID for the context user or the keyword me.
action
Type: ConnectApi.​RecommendationActionType
Specifies the action to take on a recommendation. Supported values are:
  • follow—Follow a file, record, topic, or user.
  • join—Join a group.
  • view—View a file, group, article, record, user, custom, or static recommendation.
objectId
Type: String
Specifies the object to take action on.
  • If action is follow, objectId is a user ID, file ID, record ID, or topic ID (version 36.0 and later).
  • If action is join, objectId is a group ID.
  • If action is view, objectId is a custom recommendation ID, the enum Today for static recommendations, or an article ID (version 37.0 and later).

Return Value

Type: Void

rejectRecommendationForUser(communityId, userId, action, objectEnum)

Rejects the static recommendation for the context user.

API Version

34.0

Requires Chatter

Yes

Signature

public static rejectRecommendationForUser(String communityId, String userId, ConnectApi.RecommendationActionType action, ConnectApi.RecommendedObjectType objectEnum)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
userId
Type: String
The ID for the context user or the keyword me.
action
Type: ConnectApi.​RecommendationActionType
Specifies the action to take on a recommendation. Supported values are:
  • view—View a static recommendation.
objectEnum
Type: ConnectApi.​RecommendedObjectType
Specifies the object type to take action on.
  • Today—Static recommendations that don’t have an ID, for example, the Today app recommendation.

Return Value

Type: Void

updateRecommendationAudience(communityId, recommendationAudienceId, recommendationAudience)

Update a recommendation audience.

API Version

35.0

Requires Chatter

No

Signature

public static ConnectApi.RecommendationAudience updateRecommendationAudience(String communityId, String recommendationAudienceId, ConnectApi.RecommendationAudienceInput recommendationAudience)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
recommendationAudienceId
Type: String
ID of the recommendation audience.
recommendationAudience
Type: ConnectApi.RecommendationAudienceInput
A ConnectApi.RecommendationAudienceInput object.

Return Value

Type: ConnectApi.​RecommendationAudience

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

updateRecommendationDefinition(communityId, recommendationDefinitionId, name, title, actionUrl, actionUrlName, explanation)

Update a recommendation definition with the specified parameters.

API Version

35.0

Requires Chatter

No

Signature

public static ConnectApi.RecommendationDefinition updateRecommendationDefinition(String communityId, String recommendationDefinitionId, String name, String title, String actionUrl, String actionUrlName, String explanation recommendationDefinition)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
recommendationDefinitionId
Type: String
ID of the recommendation definition.
name
Type: String
The name of the recommendation definition. The name is displayed in Setup.
title
Type: String
The title of the recommendation definition.
actionUrl
Type: String
The URL for acting on the recommendation, for example, the URL to join a group.
actionUrlName
Type: String
The text label for the action URL in the user interface, for example, “Launch.”
explanation
Type: String
The explanation, or body, of the recommendation.

Return Value

Type: ConnectApi.RecommendationDefinition

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

updateRecommendationDefinition(communityId, recommendationDefinitionId, recommendationDefinition)

Update a recommendation definition.

API Version

35.0

Requires Chatter

No

Signature

public static ConnectApi.RecommendationDefinition updateRecommendationDefinition(String communityId, String recommendationDefinitionId, ConnectApi.RecommendationDefinitionInput recommendationDefinition)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
recommendationDefinitionId
Type: String
ID of the recommendation definition.
recommendationDefinition
Type: ConnectApi.RecommendationDefinitionInput
A ConnectApi.RecommendationDefinitionInput object containing the properties to update.

Return Value

Type: ConnectApi.RecommendationDefinition

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

updateRecommendationDefinitionPhoto(communityId, recommendationDefinitionId, fileUpload)

Update a recommendation definition photo with a file that hasn’t been uploaded.

API Version

35.0

Requires Chatter

Yes

Signature

public static ConnectApi.Photo updateRecommendationDefinitionPhoto(String communityId, String recommendationDefinitionId, ConnectApi.BinaryInput fileUpload)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
recommendationDefinitionId
Type: String
ID of the recommendation definition.
fileUpload
Type: ConnectApi.Binary​​Input
A file to use as the photo. The content type must be usable as an image.

Return Value

Type: ConnectApi.Photo

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

updateRecommendationDefinitionPhoto(communityId, recommendationDefinitionId, fileId, versionNumber)

Update a recommendation definition photo with a file that’s already uploaded.

API Version

35.0

Requires Chatter

Yes

Signature

public static ConnectApi.Photo updateRecommendationDefinitionPhoto(String communityId, String recommendationDefinitionId, String fileId, Integer versionNumber)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
recommendationDefinitionId
Type: String
ID of the recommendation definition.
fileId
Type: String
ID of a file already uploaded. The file must be an image, and be smaller than 2 GB.
versionNumber
Type: Integer
Version number of the existing file. Specify either an existing version number, or null to get the latest version.

Return Value

Type: ConnectApi.Photo

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

updateRecommendationDefinitionPhotoWithAttributes(communityId, recommendationDefinitionId, photo)

Update a recommendation definition photo with a file that’s been uploaded but requires cropping.

API Version

35.0

Requires Chatter

Yes

Signature

public static ConnectApi.Photo updateRecommendationDefinitionPhotoWithAttributes(String communityId, String recommendationDefinitionId, ConnectApi.PhotoInput photo)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
recommendationDefinitionId
Type: String
ID of the recommendation definition.
photo
Type: ConnectApi.PhotoInput
A ConnectApi.PhotoInput object specifying the file ID, version number, and cropping parameters.

Return Value

Type: ConnectApi.Photo

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

updateRecommendationDefinitionPhotoWithAttributes(communityId, recommendationDefinitionId, photo, fileUpload)

Update a recommendation definition photo with a file that hasn’t been uploaded and requires cropping.

API Version

35.0

Requires Chatter

Yes

Signature

public static ConnectApi.Photo updateRecommendationDefinitionPhotoWithAttributes(String communityId, String recommendationDefinitionId, ConnectApi.PhotoInput photo, ConnectApi.BinaryInput fileUpload)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
recommendationDefinitionId
Type: String
ID of the recommendation definition.
photo
Type: ConnectApi.PhotoInput
A ConnectApi.PhotoInput object specifying the cropping parameters.
fileUpload
Type: ConnectApi.Binary​​Input
A file to use as the photo. The content type must be usable as an image.

Return Value

Type: ConnectApi.Photo

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

updateScheduledRecommendation(communityId, scheduledRecommendationId, scheduledRecommendation)

Update a scheduled recommendation.

API Version

35.0

Requires Chatter

No

Signature

public static ConnectApi.ScheduledRecommendation updateScheduledRecommendation(String communityId, String scheduledRecommendationId, ConnectApi.ScheduledRecommendationInput scheduledRecommendation)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
scheduledRecommendationId
Type: String
ID of the scheduled recommendation.
scheduledRecommendation
Type: ConnectApi.ScheduledRecommendationInput
A ConnectApi.ScheduledRecommendationInput object containing the properties to update.

Return Value

Type: ConnectApi.ScheduledRecommendation

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

Ranking scheduled recommendations example

If you have these scheduled recommendations:

Scheduled Recommendations Rank
ScheduledRecommendationA 1
ScheduledRecommendationB 2
ScheduledRecommendationC 3

And you include this information in the Scheduled Recommendation Input:

Scheduled Recommendation Rank
ScheduledRecommendationD 2

The result is:

Scheduled Recommendation Rank
ScheduledRecommendationA 1
ScheduledRecommendationD 2
ScheduledRecommendationB 3
ScheduledRecommendationC 4

updateScheduledRecommendation(communityId, scheduledRecommendationId, rank, enabled, recommendationAudienceId)

Update a scheduled recommendation with the specified parameters.

API Version

35.0

Requires Chatter

No

Signature

public static ConnectApi.ScheduledRecommendation updateScheduledRecommendation(String communityId, String scheduledRecommendationId, Integer rank, Boolean enabled, String recommendationAudienceId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
scheduledRecommendationId
Type: String
ID of the scheduled recommendation.
rank
Type: Integer
Relative rank of the scheduled recommendation indicated by ascending whole numbers starting with 1.

Setting the rank is comparable to an insertion into an ordered list. The scheduled recommendation is inserted into the position specified by the rank. The rank of all the scheduled recommendations after it is pushed down. See Ranking scheduled recommendations example.

If the specified rank is larger than the size of the list, the scheduled recommendation is put at the end of the list. The rank of the scheduled recommendation is the size of the list, instead of the one specified.

If a rank is not specified, the scheduled recommendation is put at the end of the list.

enabled
Type: Boolean
Indicates whether scheduling is enabled. If true, the recommendation is enabled and appears in communities. If false, recommendations in feeds in the Salesforce mobile web aren’t removed, but no new recommendations appear. In Customer Service and Partner Central communities, disabled recommendations no longer appear.
recommendationAudienceId
Type: String
ID of the recommendation definition that this scheduled recommendation schedules.

Return Value

Type: ConnectApi.ScheduledRecommendation

Usage

Community managers (users with the Create and Set Up Communities or Manage Communities permission) can access, create, and delete audiences, definitions, and schedules for community recommendations. Users with the Modify All Data permission can also access, create, and delete recommendation audiences, recommendation definitions, and scheduled recommendations.

Ranking scheduled recommendations example

If you have these scheduled recommendations:

Scheduled Recommendations Rank
ScheduledRecommendationA 1
ScheduledRecommendationB 2
ScheduledRecommendationC 3

And you include this information in the Scheduled Recommendation Input:

Scheduled Recommendation Rank
ScheduledRecommendationD 2

The result is:

Scheduled Recommendation Rank
ScheduledRecommendationA 1
ScheduledRecommendationD 2
ScheduledRecommendationB 3
ScheduledRecommendationC 4

Recommendations Test Methods

The following are the test methods for Recommendations. All methods are static.

For information about using these methods to test your ConnectApi code, see Testing ConnectApi Code.

setTestGetRecommendationForUser(communityId, userId, action, objectId, result)

Registers a ConnectApi.RecommendationCollection object to be returned when getRecommendationForUser is called with matching parameters in a test context. Use the method with the same parameters or the code throws an exception.

API Version

33.0

Requires Chatter

Yes

Signature

public static Void setTestGetRecommendationForUser(String communityId, String userId, ConnectApi.RecommendationActionType action, String objectId, ConnectApi.RecommendationCollection result)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
userId
Type: String
The ID for the context user or the keyword me.
action
Type: ConnectApi.​RecommendationActionType
Specifies the action to take on a recommendation.
  • follow—Follow a file, record, topic, or user.
  • join—Join a group.
  • view—View a file, group, article, record, user, custom, or static recommendation.
objectId
Type: String
Specifies the object to take action on.
  • If action is follow, objectId is a user ID, file ID, record ID, or topic ID (version 36.0 and later).
  • If action is join, objectId is a group ID.
  • If action is view, objectId is a user ID, file ID, group ID, record ID, custom recommendation ID, the enum Today for static recommendations, or an article ID (version 37.0 and later).
result
Type: ConnectApi.RecommendationCollection
The object containing test data.

Return Value

Type: Void

setTestGetRecommendationsForUser(communityId, userId, contextAction, contextObjectId, maxResults, result)

Registers a ConnectApi.RecommendationCollection object to be returned when getRecommendationsForUser is called with matching parameters in a test context. Use the method with the same parameters or the code throws an exception.

API Version

Requires Chatter

Yes

Signature

public static Void setTestGetRecommendationsForUser(String communityId, String userId, ConnectApi.RecommendationActionType contextAction, String contextObjectId, Integer maxResults, ConnectApi.RecommendationCollection result)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
userId
Type: String
The ID for the context user or the keyword me.
contextAction
Type: ConnectApi.​RecommendationActionType
Action that the context user just performed. Supported values are:
  • follow
  • view
Use contextAction and contextObjectId together to get new recommendations based on the action just performed. If you don’t want recommendations based on a recent action, specify null.
contextObjectId
Type: String
ID of the object that the context user just performed an action on.
  • If contextAction is follow, contextObjectId is a user ID, file ID, or record ID.
  • If contextAction is view, contextObjectId is a user ID, file ID, group ID, or record ID.
Use contextAction and contextObjectId together to get new recommendations based on the action just performed. If you don’t want recommendations based on a recent action, specify null.
maxResults
Type: Integer
Maximum number of recommendation results; default is 10. Values must be from 1 to 99.
result
Type: ConnectApi.RecommendationCollection
The object containing test data.

Return Value

Type: Void

setTestGetRecommendationsForUser(communityId, userId, contextAction, contextObjectId, channel, maxResults, result)

Registers a ConnectApi.RecommendationCollection object to be returned when getRecommendationsForUser is called with matching parameters in a test context. Use the method with the same parameters or the code throws an exception.

API Version

36.0

Requires Chatter

Yes

Signature

public static Void setTestGetRecommendationsForUser(String communityId, String userId, ConnectApi.RecommendationActionType contextAction, String contextObjectId, ConnectApi.RecommendationChannel channel, Integer maxResults, ConnectApi.RecommendationCollection result)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
userId
Type: String
The ID for the context user or the keyword me.
contextAction
Type: ConnectApi.​RecommendationActionType
Action that the context user just performed. Supported values are:
  • follow
  • view
Use contextAction and contextObjectId together to get new recommendations based on the action just performed. If you don’t want recommendations based on a recent action, specify null.
contextObjectId
Type: String
ID of the object that the context user just performed an action on.
  • If contextAction is follow, contextObjectId is a user ID, file ID, record ID, or topic ID.
  • If contextAction is view, contextObjectId is a user ID, file ID, group ID, record ID, or article ID (version 37.0 and later).
Use contextAction and contextObjectId together to get new recommendations based on the action just performed. If you don’t want recommendations based on a recent action, specify null.
channel
Type: ConnectApi.RecommendationChannel
A way to tie recommendations together, for example, to display recommendations in specific places in the UI or to show recommendations based on time of day or geographic locations. Values are:
  • CustomChannel1Custom recommendation channel. Not used by default. Work with your community manager to define custom channels. For example, community managers can use Community Builder to determine where recommendations appear.
  • CustomChannel2—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • CustomChannel3—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • CustomChannel4—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • CustomChannel5—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • DefaultChannel—Default recommendation channel. Recommendations appear by default on the Home and Question Detail pages of Customer Service and Partner Central communities. They also appear in the feed in communities in the Salesforce mobile web and anywhere community managers add recommendations using Community Builder.
maxResults
Type: Integer
Maximum number of recommendation results; default is 10. Values must be from 1 to 99.
result
Type: ConnectApi.RecommendationCollection
The object containing test data.

Return Value

Type: Void

setTestGetRecommendationsForUser(communityId, userId, action, contextAction, contextObjectId, maxResults, result)

Registers a ConnectApi.RecommendationCollection object to be returned when getRecommendationsForUser is called with matching parameters in a test context. Use the method with the same parameters or the code throws an exception.

API Version

Requires Chatter

Yes

Signature

public static Void setTestGetRecommendationsForUser(String communityId, String userId, ConnectApi.RecommendationActionType action, ConnectApi.RecommendationActionType contextAction, String contextObjectId, Integer maxResults, ConnectApi.RecommendationCollection result)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
userId
Type: String
The ID for the context user or the keyword me.
action
Type: ConnectApi.​RecommendationActionType
Specifies the action to take on a recommendation.
  • follow—Follow a file, record, topic, or user.
  • join—Join a group.
  • view—View a file, group, article, record, user, custom, or static recommendation.
contextAction
Type: ConnectApi.​RecommendationActionType
Action that the context user just performed. Supported values are:
  • follow
  • view
Use contextAction and contextObjectId together to get new recommendations based on the action just performed. If you don’t want recommendations based on a recent action, specify null.
contextObjectId
Type: String
ID of the object that the context user just performed an action on.
  • If contextAction is follow, contextObjectId is a user ID, file ID, or record ID.
  • If contextAction is view, contextObjectId is a user ID, file ID, group ID, or record ID.
Use contextAction and contextObjectId together to get new recommendations based on the action just performed. If you don’t want recommendations based on a recent action, specify null.
maxResults
Type: Integer
Maximum number of recommendation results; default is 10. Values must be from 1 to 99.
result
Type: ConnectApi.RecommendationCollection
The object containing test data.

Return Value

Type: Void

setTestGetRecommendationsForUser(communityId, userId, action, contextAction, contextObjectId, channel, maxResults, result)

Registers a ConnectApi.RecommendationCollection object to be returned when getRecommendationsForUser is called with matching parameters in a test context. Use the method with the same parameters or the code throws an exception.

API Version

36.0

Requires Chatter

Yes

Signature

public static Void setTestGetRecommendationsForUser(String communityId, String userId, ConnectApi.RecommendationActionType action, ConnectApi.RecommendationActionType contextAction, String contextObjectId, ConnectApi.RecommendationChannel channel, Integer maxResults, ConnectApi.RecommendationCollection result)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
userId
Type: String
The ID for the context user or the keyword me.
action
Type: ConnectApi.​RecommendationActionType
Specifies the action to take on a recommendation.
  • follow—Follow a file, record, topic, or user.
  • join—Join a group.
  • view—View a file, group, article, record, user, custom, or static recommendation.
contextAction
Type: ConnectApi.​RecommendationActionType
Action that the context user just performed. Supported values are:
  • follow
  • view
Use contextAction and contextObjectId together to get new recommendations based on the action just performed. If you don’t want recommendations based on a recent action, specify null.
contextObjectId
Type: String
ID of the object that the context user just performed an action on.
  • If contextAction is follow, contextObjectId is a user ID, file ID, record ID, or topic ID.
  • If contextAction is view, contextObjectId is a user ID, file ID, group ID, record ID, or article ID (version 37.0 and later).
Use contextAction and contextObjectId together to get new recommendations based on the action just performed. If you don’t want recommendations based on a recent action, specify null.
channel
Type: ConnectApi.RecommendationChannel
A way to tie recommendations together, for example, to display recommendations in specific places in the UI or to show recommendations based on time of day or geographic locations. Values are:
  • CustomChannel1Custom recommendation channel. Not used by default. Work with your community manager to define custom channels. For example, community managers can use Community Builder to determine where recommendations appear.
  • CustomChannel2—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • CustomChannel3—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • CustomChannel4—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • CustomChannel5—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • DefaultChannel—Default recommendation channel. Recommendations appear by default on the Home and Question Detail pages of Customer Service and Partner Central communities. They also appear in the feed in communities in the Salesforce mobile web and anywhere community managers add recommendations using Community Builder.
maxResults
Type: Integer
Maximum number of recommendation results; default is 10. Values must be from 1 to 99.
result
Type: ConnectApi.RecommendationCollection
The object containing test data.

Return Value

Type: Void

setTestGetRecommendationsForUser(communityId, userId, action, objectCategory, contextAction, contextObjectId, maxResults, result)

Registers a ConnectApi.RecommendationCollection object to be returned when getRecommendationsForUser is called with matching parameters in a test context. Use the method with the same parameters or the code throws an exception.

API Version

Requires Chatter

Yes

Signature

public static Void setTestGetRecommendationsForUser(String communityId, String userId, ConnectApi.RecommendationActionType action, String objectCategory, ConnectApi.RecommendationActionType contextAction, String contextObjectId, Integer maxResults, ConnectApi.RecommendationCollection result)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
userId
Type: String
The ID for the context user or the keyword me.
action
Type: ConnectApi.​RecommendationActionType
Specifies the action to take on a recommendation.
  • follow—Follow a file, record, topic, or user.
  • join—Join a group.
  • view—View a file, group, article, record, user, custom, or static recommendation.
objectCategory
Type: String
  • If action is follow, objectCategory is users, files, or records.
  • If action is join, objectCategory is groups.
  • If action is view, objectCategory is users, files, groups, records,custom, or apps.
You can also specify a key prefix, the first three characters of the object ID, as the objectCategory. Valid values are:
  • If action is follow, objectCategory is 005 (users), 069 (files), or 001 (accounts), for example.
  • If action is join, objectCategory is 0F9 (groups).
  • If action is view, objectCategory is 005 (users), 069 (files), 0F9 (groups), 0RD (custom recommendations), T (static recommendations), or 001 (accounts), for example.
contextAction
Type: ConnectApi.​RecommendationActionType
Action that the context user just performed. Supported values are:
  • follow
  • view
Use contextAction and contextObjectId together to get new recommendations based on the action just performed. If you don’t want recommendations based on a recent action, specify null.
contextObjectId
Type: String
ID of the object that the context user just performed an action on.
  • If contextAction is follow, contextObjectId is a user ID, file ID, or record ID.
  • If contextAction is view, contextObjectId is a user ID, file ID, group ID, or record ID.
Use contextAction and contextObjectId together to get new recommendations based on the action just performed. If you don’t want recommendations based on a recent action, specify null.
maxResults
Type: Integer
Maximum number of recommendation results; default is 10. Values must be from 1 to 99.
result
Type: ConnectApi.RecommendationCollection
The object containing test data.

Return Value

Type: Void

setTestGetRecommendationsForUser(communityId, userId, action, objectCategory, contextAction, contextObjectId, channel, maxResults, result)

Registers a ConnectApi.RecommendationCollection object to be returned when getRecommendationsForUser is called with matching parameters in a test context. Use the method with the same parameters or the code throws an exception.

API Version

36.0

Requires Chatter

Yes

Signature

public static Void setTestGetRecommendationsForUser(String communityId, String userId, ConnectApi.RecommendationActionType action, String objectCategory, ConnectApi.RecommendationActionType contextAction, String contextObjectId, ConnectApi.RecommendationChannel channel, Integer maxResults, ConnectApi.RecommendationCollection result)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
userId
Type: String
The ID for the context user or the keyword me.
action
Type: ConnectApi.​RecommendationActionType
Specifies the action to take on a recommendation.
  • follow—Follow a file, record, topic, or user.
  • join—Join a group.
  • view—View a file, group, article, record, user, custom, or static recommendation.
objectCategory
Type: String
  • If action is follow, objectCategory is users, files, records, or topics.
  • If action is join, objectCategory is groups.
  • If action is view, objectCategory is users, files, groups, records,custom, apps, or articles (version 37.0 and later).
You can also specify a key prefix, the first three characters of the object ID, as the objectCategory. Valid values are:
  • If action is follow, objectCategory is 005 (users), 069 (files), 0TO (topics), or 001 (accounts), for example.
  • If action is join, objectCategory is 0F9 (groups).
  • If action is view, objectCategory is 005 (users), 069 (files), 0F9 (groups), 0RD (custom recommendations), T (static recommendations), 001 (accounts), or kA0 (articles), for example, (version 370 and later).
contextAction
Type: ConnectApi.​RecommendationActionType
Action that the context user just performed. Supported values are:
  • follow
  • view
Use contextAction and contextObjectId together to get new recommendations based on the action just performed. If you don’t want recommendations based on a recent action, specify null.
contextObjectId
Type: String
ID of the object that the context user just performed an action on.
  • If contextAction is follow, contextObjectId is a user ID, file ID, record ID, or topic ID.
  • If contextAction is view, contextObjectId is a user ID, file ID, group ID, record ID, or article ID (version 37.0 and later).
Use contextAction and contextObjectId together to get new recommendations based on the action just performed. If you don’t want recommendations based on a recent action, specify null.
channel
Type: ConnectApi.RecommendationChannel
A way to tie recommendations together, for example, to display recommendations in specific places in the UI or to show recommendations based on time of day or geographic locations. Values are:
  • CustomChannel1Custom recommendation channel. Not used by default. Work with your community manager to define custom channels. For example, community managers can use Community Builder to determine where recommendations appear.
  • CustomChannel2—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • CustomChannel3—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • CustomChannel4—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • CustomChannel5—Custom recommendation channel. Not used by default. Work with your community manager to define custom channels.
  • DefaultChannel—Default recommendation channel. Recommendations appear by default on the Home and Question Detail pages of Customer Service and Partner Central communities. They also appear in the feed in communities in the Salesforce mobile web and anywhere community managers add recommendations using Community Builder.
maxResults
Type: Integer
Maximum number of recommendation results; default is 10. Values must be from 1 to 99.
result
Type: ConnectApi.RecommendationCollection
The object containing test data.

Return Value

Type: Void