Promoted Search Terms
Promoted search terms are useful for promoting a
Salesforce Knowledge article that you know is commonly used to resolve a support issue when an
end user’s search contains certain keywords.
Users can promote an article in search results by
associating keywords with the article in Apex (by using the SearchPromotionRule sObject) in
addition to the Salesforce user interface.
Articles must be in published status (with a PublishSatus field value of Online) for you to manage their promoted terms.
Example
This code sample shows how to add a search
promotion rule. This sample performs a query to get published articles of type
MyArticle__kav. Next, the sample creates a SearchPromotionRule sObject to promote
articles that contain the word “Salesforce” and assigns the first returned article to
it. Finally, the sample inserts this new
sObject.
1// Identify the article to promote in search results
2List<MyArticle__kav> articles = [SELECT Id FROM MyArticle__kav WHERE PublishStatus='Online' AND Language='en_US' AND Id='Article Id' WITH USER_MODE];
3
4// Define the promotion rule
5SearchPromotionRule s = new SearchPromotionRule(
6 Query='Salesforce',
7 PromotedEntity=articles[0]);
8
9// Save the new rule
10insert as user s;