Knowledge Class

Access information about trending articles in communities.

Namespace

ConnectApi

Knowledge Methods

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

getTopViewedArticlesForTopic(communityId, topicId, maxResults)

Get the top viewed articles for a topic.

API Version

41.0

Available to Guest Users

41.0

Requires Chatter

No

Signature

public static ConnectApi.KnowledgeArticleVersionCollection getTopViewedArticlesForTopic(String communityId, String topicId, Integer maxResults)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
topicId
Type: String
ID of the topic.
maxResults
Type: Integer
The maximum number of articles returned for each topic ID. Values can be from 1 to 25. The default value is 5.

getTrendingArticles(communityId, maxResults)

Get trending articles for a community.

API Version

36.0

Available to Guest Users

36.0

Requires Chatter

No

Signature

public static ConnectApi.KnowledgeArticleVersionCollection getTrendingArticles(String communityId, Integer maxResults)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
maxResults
Type: Integer
The maximum number of articles returned. Values can be from 0 to 25. Default is 5.

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.

getTrendingArticlesForTopic(communityId, topicId, maxResults)

Get the trending articles for a topic in a community.

API Version

36.0

Available to Guest Users

36.0

Requires Chatter

No

Signature

public static ConnectApi.KnowledgeArticleVersionCollection getTrendingArticlesForTopic(String communityId, String topicId, Integer maxResults)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
topicId
Type: String
ID of the topic.
maxResults
Type: Integer
The maximum number of articles returned. Values can be from 0 to 25. Default is 5.

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.

Knowledge Test Methods

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

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

setTestGetTrendingArticles(communityId, maxResults, result)

Register a ConnectApi.KnowledgeVersionArticleCollection object to be returned when the matching ConnectApi.getTrendingArticles method is called in a test context. Use the method with the same parameters or you receive an exception.

API Version

36.0

Signature

public static Void setTestGetTrendingArticles(String communityId, Integer maxResults, ConnectApi.KnowledgeArticleVersionCollection result)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
maxResults
Type: Integer
The maximum number of articles returned. Values can be from 0 to 25. Default is 5.
result
Type: ConnectApi.KnowledgeArticleVersionCollection
The object containing test data.

Return Value

Type: Void

setTestGetTrendingArticlesForTopic(communityId, topicId, maxResults, result)

Register a ConnectApi.KnowledgeVersionArticleCollection object to be returned when the matching ConnectApi.getTrendingArticlesForTopic method is called in a test context. Use the method with the same parameters or you receive an exception.

API Version

36.0

Signature

public static Void setTestGetTrendingArticlesForTopic(String communityId, String topicId, Integer maxResults, ConnectApi.KnowledgeArticleVersionCollection result)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
topicId
Type: String
ID of the topic.
maxResults
Type: Integer
The maximum number of articles returned. Values can be from 0 to 25. Default is 5.
result
Type: ConnectApi.KnowledgeArticleVersionCollection
The object containing test data.

Return Value

Type: Void