Skip to main content
Oliver Westlake-Simm (Medallia) 님이 #Apex에 질문했습니다
I'm trying to create an Invocable Apex Class to Search Articles within Einstein bots. I'm using the "Einstein Bot Cookbook for Intermediate Developers" pdf which provides the following but i'm getting an Illegal string literal: Line breaks are not allowed in string literals error when trying to run.

String sArticleBaseUrl = getCommunityArticleBaseUrl();

        String sKeyword = faqSearchInput[0].sKeyword;

        String sQuery = 'FIND \'' + sKeyword + '\' IN ALL FIELDS RETURNING

            KnowledgeArticleVersion(Id, Title, UrlName WHERE PublishStatus = \'Online\'

                                    AND Language = \'en_US\' AND IsVisibleInPkb = true) WITH SNIPPET

                                    (target_length=255) LIMIT 3';

                                    Search.SearchResults searchResults = Search.find(sQuery);

                                    List<Search.SearchResult> articlelist =

                                    searchResults.get('KnowledgeArticleVersion');

                                    String sFAQSearchResult = '';

                                    for (Search.SearchResult searchResult : articlelist)
답변 1개
  1. 2018년 12월 12일 오전 8:37
    Hi,

    When you copied the code line breaks might have copied. I would suggest you to remove the space from each line or on the line where you are getting this error.

    Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.

                                                 

    Best Regards

    Sandhya

     

     
0/9000