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
Vanitha ManiVanitha Mani 

attachments in lightning component

Hi,

My requirement is to search for knowledge article and attach the searched article to the case object using  aura lightning component.Can anyone help me with this?

Thanks,
AnudeepAnudeep (Salesforce Developers) 
You need to do a SOSL to find knowledge articles first. Here is a sample code
 
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;

}

}

You need to utilize this result in the controller and associate the article to case object. See this post for sample code

NOTE: The code provided is an example. You'll need to review and make modifications for your organization.
Vanitha ManiVanitha Mani
@Anudeep..I got the knowledge result but unable to attach to the case..Can u help me with that code.
User-added image
I added the attach button to each of them..once i clicked it need to link to the case related list named articles here in this image below.
User-added image

Thanks