Automatically index template tables (u_kb_template_)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi everyone
Please your help, when searching for articles with custom templates (with prefix u_kb_template) from the Employee Center portal, I cannot see the articles until I manually add the table in ALL > AI Search > AI Search> Indexed Sources > Knowledge table and submit it for indexing. Is there a way to automatically index the child tables of knowledge as they are created?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Proposed Customization: Automatic Indexing on KB Table Insert
When you open the UI Action: Index Selected Table/s,
it has the UI Page invoked: ais_index_single_table
open ui page- "ais_index_single_table"
This UI page sets sys_id and datasource values, which are later accessed in the client-side script.
The script executed on this page is responsible for indexing a specific table, as shown below:
function index() {
var table = gel('table').value;
var gm = GlideModal.prototype.get('ais_index_single_table');
var sysId = gm.getPreference('sys_id');
var datasource = gm.getPreference('datasource');
if (!table) {
alert(new GwtMessage().getMessage("Please select a table to be indexed"));
return false;
}
var ga = new GlideAjax('AisConfigurationAjax');
ga.addParam('sysparm_name', 'indexSingleTableNoBlocking');
ga.addParam('sysparm_ais_datasource', datasource);
ga.addParam('sysparm_ais_table', table);
ga.getXML(function(response) {
var id = response.responseXML.documentElement.getAttribute("answer");
if (id) {
var url = '/ais_ingest_datasource_stats.do?sys_id=' + id;
window.location = url;
}
});
}
Recommendation- I recommend implementing either:
A Scheduled Job, or
A Business Rule (on insert) for the Knowledge Base (KB) table
This would automatically invoke the indexSingleTableNoBlocking method from the AisConfigurationAjax Script Include whenever a new KB record is inserted—eliminating the need for manual indexing via the UI.
Let me know if you'd like help drafting the business rule or schedule logic!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Thanks @Ajay_Chavan for your response, if you can help me with that business rule I would really appreciate it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
give it a try:
function getKnowledgeBaseDatasource() {
var ds = new GlideRecord('ais_datasource');
ds.addQuery('source', 'kb_knowledge');
ds.addQuery('active', true);
ds.query();
return ds.next() ? ds.sys_id.toString() : '';
}
var datasource = getKnowledgeBaseDatasource();
gs.info(datasource);
if (datasource) {
var aisConfig = new AisConfigurationAjax();
aisConfig.indexSingleTableNoBlocking(datasource, 'kb_knowledge');
}
// make sure you have ais_admin role