Skip to content

Commit f4790e0

Browse files
committed
fix(servicenow): restore wiki field fallback for kb_knowledge
Wiki-template KB articles populate the wiki field and leave text empty; HTML-template articles do the opposite. Removing wiki caused wiki-format articles to resolve to empty content and be silently skipped.
1 parent d3f1e66 commit f4790e0

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

apps/sim/connectors/servicenow/servicenow.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ interface ServiceNowRecord {
4242
interface KBArticle extends ServiceNowRecord {
4343
short_description?: string
4444
text?: string
45+
wiki?: string
4546
workflow_state?: string
4647
kb_category?: string | { display_value?: string }
4748
kb_knowledge_base?: string | { display_value?: string }
@@ -269,7 +270,12 @@ function priorityLabel(priority: string | undefined): string {
269270
*/
270271
function kbArticleToDocument(article: KBArticle, instanceUrl: string): ExternalDocument {
271272
const title = rawValue(article.short_description) || rawValue(article.number) || article.sys_id
272-
const articleText = rawValue(article.text) || ''
273+
/**
274+
* Wiki-template KB articles populate `wiki` with the body and leave
275+
* `text` empty; HTML-template articles do the opposite. Falling back
276+
* to `wiki` keeps both layouts indexable.
277+
*/
278+
const articleText = rawValue(article.text) || rawValue(article.wiki) || ''
273279
const content = htmlToPlainText(articleText)
274280
const sysId = rawValue(article.sys_id) || article.sys_id
275281
const updatedOn = rawValue(article.sys_updated_on) || ''
@@ -554,7 +560,7 @@ export const servicenowConnector: ConnectorConfig = {
554560
const query = isKB ? buildKBQuery(sourceConfig) : buildIncidentQuery(sourceConfig)
555561

556562
const fields = isKB
557-
? 'sys_id,short_description,text,workflow_state,kb_category,kb_knowledge_base,number,author,sys_created_by,sys_updated_by,sys_updated_on,sys_created_on'
563+
? 'sys_id,short_description,text,wiki,workflow_state,kb_category,kb_knowledge_base,number,author,sys_created_by,sys_updated_by,sys_updated_on,sys_created_on'
558564
: 'sys_id,number,short_description,description,state,priority,category,assigned_to,opened_by,close_notes,resolution_notes,sys_created_by,sys_updated_by,sys_updated_on,sys_created_on'
559565

560566
const params: Record<string, string> = {
@@ -630,7 +636,7 @@ export const servicenowConnector: ConnectorConfig = {
630636
}
631637

632638
const fields = isKB
633-
? 'sys_id,short_description,text,workflow_state,kb_category,kb_knowledge_base,number,author,sys_created_by,sys_updated_by,sys_updated_on,sys_created_on'
639+
? 'sys_id,short_description,text,wiki,workflow_state,kb_category,kb_knowledge_base,number,author,sys_created_by,sys_updated_by,sys_updated_on,sys_created_on'
634640
: 'sys_id,number,short_description,description,state,priority,category,assigned_to,opened_by,close_notes,resolution_notes,sys_created_by,sys_updated_by,sys_updated_on,sys_created_on'
635641

636642
const instanceUrl = resolveServiceNowInstanceUrl(sourceConfig.instanceUrl as string)

0 commit comments

Comments
 (0)