function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Scott McArthur 8Scott McArthur 8 

Fields on Knowledge Article Not Displayed On Lightning Component

I have a Lightning component to display a list of Knowledge Articles. The code runs ok and seems to enter the `<aura:iteration` as the colons are displayed and looking at the debug log the query is returning results however the fields themselves like Title are not displayed when I run this in developer console.

component
  
<aura:component description="ArticleList" implements="forceCommunity:availableForAllPageTypes"  controller="ArticleListController">
  
    <aura:attribute name="articles" type="SObject[]"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />

    <aura:iteration var="article" items="{!v.articles}">
        <p>{!article.Id} : {!article.Title} : {!article.ArticleType}</p>
    </aura:iteration>

    </aura:component>

controller
 
({

    doInit: function(component, event){
        var action = component.get("c.getArticles");
        action.setCallback(this, function(response){
        component.set("v.articles", response.getReturnValue());

        });
     $A.enqueueAction(action);
    }

})
  
apex controller
 
public with sharing class ArticleListController {

    @AuraEnabled
    public static List<List<SObject>> getArticles() {
        String searchVar = 'Unpredictable';
        List<List<SObject>> articles = [FIND :searchVar RETURNING      KnowledgeArticleVersion
        (Id, Title, ArticleType WHERE PublishStatus='online' AND Language = 'en_US' AND ArticleType IN ('Knowledge__kav','Attachment__kav'))];
        return articles;

    }

 }



   
    

 
Scott McArthur 8Scott McArthur 8
Was missing something obvious was returning a list of lists, have to process it into a single list and it works.
Pradeep 10Pradeep 10
Hi guys, is there any way we can show the related KB article attachment on community by retrieving related details via Lightning component.

For this, I am currently using the <ui:outputURL label="Attachment" value="{!v.articleDetail.Id}"/>  and here I am able to get the article id under the label "Attacment" but from here, I am not able to identify how to get the attachment open/ download in community.