DocEngine

Docs

Lists & queries

List (and some Choice) fields can use fixed options, shared catalogs, or live remote search. Remote lists only run in an interactive host that implements resolveListItems — not inside a static PDF render of already-filled values.

Three ways to supply options

  1. Inline items — options stored on the field schema (items: [{ id, label, value }]). Best for small fixed sets.
  2. Catalog — commonListId / commonTreeId points at lists injected via createEditor({ catalogs }).
  3. Remote — set list source to remote and sourceCollection (e.g. Account or Account.Industry). On typeahead, the editor calls the host.

Host contract: resolveListItems

Called while the user searches in fill mode:

createEditor({
  holder,
  // ...
  resolveListItems: async ({ fieldName, query, sourceCollection }) => {
    // Return [{ id, label, value?, code? }, ...]
    const key = sourceCollection || fieldName;
    const res = await fetch(`/api/lists?${new URLSearchParams({ key, q: query || '' })}`);
    return res.json();
  },
})
  • fieldName — legacy / schema name fallback
  • query — what the user typed (may be empty on open)
  • sourceCollection — from the field schema when set

Return an array of { id, label, value?, code? }. Selected values are stored as labels on List fields (string[]).

Salesforce conventions

The managed package implements remote lists in DocEngineListController.resolveListItems:

// Salesforce (DocEngineListController)
// sourceCollection = "Account.Industry"  → picklist, filtered by query
// sourceCollection = "Account"           → search Account.Name by query
  • Picklist — ObjectApiName.FieldApiName, filter active entries by query substring.
  • Record search — bare ObjectApiName, SOQL Name LIKE query (with sharing / FLS).

In the template builder, choose the remote collection when editing the List field schema so sourceCollection is saved into Template_JSON__c.

Design checklist

  • Prefer remote lists for large or org-specific catalogs.
  • Set a clear sourceLabelField when searching objects (display Name vs custom label).
  • Test empty query (initial open) and multi-character search.
  • After fill, exported values are plain labels/arrays — PDF/n8n do not re-query. Re-merge from Salesforce uses Mapping + payload instead.
  • Iframe embed: the fill page cannot call the parent’s APIs directly. The iframe posts docengine:list-query; the parent answers docengine:list-result with { id, label } rows. See API & hosts.

Next: API & hosts · Examples