Need help for Virtual Agent topic

Admin7267
Kilo Sage

I have a requirement of showing KB articles as choices in Virtual Agent based keywords entered by user. 

If user search for laptop then need to display the KB articles that contains laptop keyword in KB article Short Description or Article Body. 

 

I have created a topic and used script action with below code and it's not working. 

searchArticles: function() {
        var searchQuery = this.getParameter('search_query').toLowerCase();
        var matchingArticles = [];
        var articleGr = new GlideRecord('kb_knowledge');
        articleGr.addQuery('short_description', 'LIKE', '%' + searchQuery + '%');
        articleGr.addOrCondition('description', 'LIKE', '%' + searchQuery + '%');
        articleGr.query();

        while (articleGr.next()) {
            matchingArticles.push({
                id: articleGr.getValue('sys_id'),
                title: articleGr.getValue('short_description')
            });
        }
        return matchingArticles;
    },
1 REPLY 1

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

Can you also explain what exactly is not working? What you debugged? Up to where it is working, from where it is failing? And where are you exactly applying this in your Topic, did you verify its the correct place or can you share it?

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn