Kysoql
Salesforce-specific features

Knowledge and feed queries

Use the extra filters and clauses required by Salesforce Knowledge and feed objects.

Generate the relevant Knowledge or feed objects first. Availability depends on your org and the permissions of the generation identity.

Knowledge root filters

KnowledgeArticleVersion and article-version objects ending in __kav need a root filter on PublishStatus or Id:

import { db } from "./db";

const query = db
  .selectFrom("KnowledgeArticleVersion")
  .select(["Id", "Title"])
  .where("PublishStatus", "=", "Online")
  .limit(50);

Kysoql checks that basic shape locally. Salesforce can still apply additional Knowledge restrictions. Apex Knowledge queries do not accept Kysoql bind expressions.

WITH DATA CATEGORY

import { db } from "./db";

const query = db
  .selectFrom("KnowledgeArticleVersion")
  .select(["Id", "Title"])
  .where("PublishStatus", "=", "Online")
  .withDataCategory("Geography__c", "at", ["usa__c", "france__c"])
  .withDataCategory("Product__c", "below", "mobile_phones__c");

Category groups and category names come from generated metadata. Supported selectors are at, above, below, and above_or_below.

A query can contain up to three data-category conditions and cannot repeat a category group. This clause is available on Question, KnowledgeArticleVersion, and concrete __kav article versions.

Tracking and view statistics

import { db } from "./db";

const query = db
  .selectFrom("FAQ__kav")
  .select(["Id", "Title"])
  .where("PublishStatus", "=", "Online")
  .updateTracking()
  .updateViewstat();

These methods emit Knowledge UPDATE TRACKING and VIEWSTAT clauses. They can have observable side effects, so account for that before automatically retrying a request.

UserProfileFeed

import { db } from "./db";

const query = db
  .selectFrom("UserProfileFeed")
  .select(["Id", "CreatedDate"])
  .withUserId("005000000000001AAA")
  .orderBy("CreatedDate", "desc")
  .limit(20);

UserProfileFeed requires withUserId(). NewsFeed and UserProfileFeed also reject relationship-path sorting.

For other object-specific query shapes, see support boundaries.

On this page