7

We have implemented the Napili template for our Customer Community. We have many articles with associated categories, and have added Category/Product Tiles to the main page. You can click a tile and get a list of every article associated with that category, however, when you search a specific term in the search box, it returns articles from every category.

Is there a way to limit the resulting list to only articles with the associated categories related to the tile (category/product) clicked? By built-in settings or by additional programming?

1
  • 1
    the out of the box record list component does not support this, you will have to build a custom lightning component to achieve this.
    – glls
    May 1 '17 at 21:39
1

If you are meaning data categories and data category groups, then the old Koa and Kokua community templates had data category filter lightning components. These are not available in any other community. With Koa and Kokua no longer being available, it means there are no out of the box solutions for this.

I have created a Salesforce idea concerning this - but at this stage there is no easy filtering option available for napili template based communities.

https://success.salesforce.com/ideaView?id=0873A000000lIA1QAM

0

As a Salesforce partner --> Coveo (My employer) released a Free Search Solution via the appexchange (and we have a component for Lightning communities). Although Data Categories are Not supported Out of the Box with the free version (yet), we currently implement Data Category filtering by doing a series of configurations in order to surface the data categories and use them as filters in our facets.

On the Knowledge Type(s), you would need to Create a Custom Multi-Value Field in order to Map DataCategories to it. Then, you need to create an Apex class with an Invocable method which will be invoked whenever a Knowledge article of specific type is added or edited.

Here is a code snippet to achieve this:

public class DataCategoryMgmt {

    @InvocableMethod
    public static void updateArticleTypeForDataCategories(List<Id> articleTypeIds)
    {
        List<Knowledge__kav> lstArticleType = [SELECT Id, Title, Data_Categories__c FROM Knowledge__kav WHERE Id IN:articleTypeIds
                                                    AND PublishStatus = 'draft'];

        List<Knowledge__DataCategorySelection> lstDC = [SELECT ParentId, DataCategoryName   FROM Knowledge__DataCategorySelection
                                                            WHERE ParentId IN:articleTypeIds];

        Map<Id, String> datacategoryNameMap = new Map<Id, String>();

        for(Knowledge__DataCategorySelection dcObj:lstDC)
        {  
            if(datacategoryNameMap.containsKey(dcObj.ParentId))
            {
                String str =  datacategoryNameMap.get(dcObj.ParentId);
                datacategoryNameMap.put(dcObj.ParentId, str + ';' + dcObj.DataCategoryName);
            }
            else
            {
                datacategoryNameMap.put(dcObj.ParentId, dcObj.DataCategoryName);
            }
        }

        for(Knowledge__kav artObj:lstArticleType)
        {
            if(datacategoryNameMap.containsKey(artObj.Id))
            {
                artObj.Data_Categories__c = datacategoryNameMap.get(artObj.Id);
            }
        }

        update lstArticleType;
    }   
}

In the above example, I named the custom field Data_Categories__c and Knowledge can be replaced with the Article Type from your org.

Finally, I created a Process Builder in order to Invoce My apex class's Invocable method. When you setup your Apex Class Variable, make sure you reference the Knowledge Article Version Id.

Finally, when you are at the search interface (as an admin) you can access the interface editor: enter image description here

And drag and drop a facet component that references your new custom field.

However, prior to all of this, you might want to get familiar with Getting Started with Coveo for Salesforce Free Edition

Using Data Category filtering with Knowledge Articles

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.