Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Table Configuration's Scripted Filter Condition Not Working

MattDever
Tera Contributor

I have a requirement from a customer seeking the following be solved:

  • In workspace Agent Assist, only show knowledge articles for a predefined group of knowledge bases
    • Applies to Incident, Request, and Incident Management
  • Apply this filter to only specified groups

After scouring through a plethora of online resources for setting up agent assist filters (i.e. using a script on a "Filter Condition" in a "Table Configuration" record), I have yet to find any that meet the requirements I current have.

 

Here is the code I have been using, just to get the knowledge article results, for now:

(function(current, query_table) {
    /**
     * current: A GlideRecord representing the Form or Record producer
     * query_table: The table to compare value on
     *
     * Use the standard query features of GlideRecord to add conditions to query_table.
     * Current prepresents the current values on the user's form or record producer that
     * can be used to add live conditions to the query.
     *
     * E.g. query_table.addQuery("active", current.active);
     *
     * The return value should always be the encoded query, usually query_table.getEncodeQuery()
     */

    // get the sys_ids from the value of the knowledge base sys_properties 'service_desk_agent_assist'
	var sdAgentKbs = gs.getProperty('service_desk_agent_assist');
    query_table.addActiveQuery();

    // filter for those knowledge articles that are published
	query_table.addQuery('workflow_state', 'published');

	// filter for those knowledge articles in the knowledge bases retrieved from the sys_properties record
    query_table.addQuery('kb_knowledge_base.sys_idIN' + sdAgentKbs); 	// NOTE: this script statement works as written in Scripts Background
// }

/* 
This script works in Scripts Background using the following code, but is NOT producing the same results in the "Filter Condition" of the "Table Configuration":

	var sdAgentKbs = gs.getProperty('service_desk_agent_assist');
    var query_table = new GlideRecord('kb_knowledge');
	query_table.addActiveQuery();
    query_table.addQuery('workflow_state', 'published');
    query_table.addQuery('kb_knowledge_base.sys_idIN' + sdAgentKbs);
	query_table.orderBy('kb_knowledge_base.title');
	query_table.query();

*/
return query_table.getEncodedQuery(); // Return the encoded query  

})(current, query_table);

 

Has anyone encountered this scenario, before, where there need to be multiple filters in place with a sys_properties record that can be altered to satisfy requirements (e.g., adding/removing knowledge base sys_ids) that may change in the future?

 

Yes, I have clicked through a number of URLs in other community posts related to scripted "Filter Conditions" on "Table Configurations" for agent assist.

 

Thank you, in advance, for any assistance you can provide.

2 REPLIES 2

RaghavSh
Mega Patron

I believe you have used the syntax of EncodedQuery , try updating below:

query_table.addEncodedQuery('kb_knowledge_base.sys_idIN' + sdAgentKbs);

 


Raghav
MVP 2023
LinkedIn

Hi RaghavSh:

Thank you for your quick response and suggested correction.  I made the change you recommended and unfortunately I am still not seeing the expected results. 🙁

 

For example:

* Interaction's short description: "Pulse"

* Workspace Agent Assist results: 1 (from one of the filtered knowledge bases but not related to or contains "Pulse" in the article)

* Expected Agent Assist results: 5 (from 4 of the filtered knowledge bases)