I am trying to build a lightning component that will be used as a help landing page for one of our products. So I will be filtering the data category from apex and further filters by search terms using SOSL. Here is what I have so far but I am not getting any results in the component.
.cmp
<aura:component implements="forceCommunity:availableForAllPageTypes" controller="GetHBArticles">
<aura:attribute name="articles" type="SObject[]"/>
<ui:button label="Get Articles" press="{!c.getArts}"/>
<aura:iteration var="articles" items="{!v.articles}">
<p>{!articles.Id} : {!articles.Title} : {!articles.ArticleType}</p>
</aura:iteration>
</aura:component>
lightning controller
({
getOpps: function(cmp){
var action = cmp.get("c.getArts");
action.setCallback(this, function(response){
var state = response.getState();
if (state === "SUCCESS") {
cmp.set("v.articles", response.getReturnValue());
}
});
$A.enqueueAction(action);
}
})
apex controller
public with sharing class GetHBArticles {
@AuraEnabled
public static List<List<SObject>> getArticlesList(){
List<List<SObject>> articles = [FIND :searchVar RETURNING KnowledgeArticleVersion
(Id, Title, ArticleType WHERE PublishStatus='online' AND Language = 'en_US' AND ArticleType IN ('Troubleshooting__kav', 'How_To__kav', 'FAQ__kav'))
WITH DATA CATEGORY Topics__c AT 'DataCategoryName];
return articles;
}
}
Here is the error I see in the Chrome dev console when I click the button.
Also, I received a suggestion to map the id's of articles and build a wrapper class to traverse the KnowledgeArticleVersion object to KnowledgeArticle in order to sort the results by CaseAssociationCount. I would love to hear from anyone that has any examples of how I can do this. I have been reading up on it but I am spending a bit more time on it then I had hoped.
As always any help from this awesome group is greatly appreciated.