2

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. Browser Debug

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.

1
  • what is searchVar in your apex controller?
    – Bhupendra
    Commented Jun 29, 2016 at 9:16

1 Answer 1

2

A couple things here:
1. the button "press" action is looking for the controller method getArts but your controller's method is named getOpps
2. In your controller method, the method name you should be calling is the name of the Apex method, i.e.: var action = cmp.get("c. getArticlesList");

This should give you a start at least.

1
  • Awesome! Thank you this worked. I can see my articles coming through in dev console.
    – Allen Mann
    Commented Apr 6, 2016 at 13:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .