Need help for Virtual Agent topic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2024 08:27 PM
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;
},

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2024 09:48 PM
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