Custom Code Examples

These examples explain common patterns, configuration, and implementation approach without publishing full template files on the documentation page.

Production-ready reusable templates should keep the full code file and user guide together in a dedicated template folder.

Yeeflow runtimeForms, data lists, dashboards
context.paramsfieldsValuesgetFieldValue()yeeSDKClientreadonly

Pair examples with reusable templates

Use the examples below to understand the pattern, then open the Custom Code template library to review complete TSX source, user guides, and example configuration.

Simple parameter demo

Confirm that a custom code control can read configuration from context.params and render it safely.

ParameterTypePurpose
titleTextstringTitle shown in the control.
bodyTextstringShort message shown below the title.
tonestringOptional visual tone such as blue, green, or slate.
  • Define inputParameters(), read context.params, pass values into a React component, and render a compact information block.
  • Do not query data or save output. Keep this example focused on parameter handling and rendering.

Configurable monthly table

Help users enter, review, or display month-based business values such as budgets, forecasts, resource plans, or progress updates.

ParameterTypePurpose
yearFieldNamestring or variableCurrent form field that stores the year.
monthFieldNamestring or variableCurrent form field that stores the selected month.
tableConfigvariableJSON configuration for rows, columns, labels, or defaults.
saveToFieldvariableField where structured table output is saved.
readonlyModeTextstringOptional text shown when editing is disabled.
  • Read current form values from fieldsValues and context.getFieldValue(), build a row model, render a stable table, and save structured output when users edit values.
  • Use safe numeric parsing for totals and render values as text in readonly mode.
[
  {
    "month": "2026-01",
    "planned": 12000,
    "actual": 9800,
    "notes": "Awaiting final invoice"
  }
]

Dashboard analytics component

Summarize business performance using KPI cards, charts, or compact analysis tables.

ParameterTypePurpose
dataListIdvariableSource data list to query.
titleTextstringDashboard module title.
pageSizestringNumber of records to query per page.
filterFieldvariableOptional field used for dashboard filtering.
filterValuevariableOptional filter value from a variable or temp variable.
  • Check yeeSDKClient availability, query records with pagination, normalize row values, aggregate results, then render loading, error, empty, and loaded states.
  • Avoid loading more data than the dashboard needs and document expected dashboard variable values.

Smart lookup picker concept

Let users search a Yeeflow data list, select one or more records, and save structured output.

ParameterTypePurpose
dataListIdvariableData list to search.
displayFieldvariableField shown in search results.
valueFieldvariableField saved as the selected value.
saveToFieldvariableField or temp variable for full output JSON.
selectedItemsFieldvariableOptional target for selected source values only.
newItemsFieldvariableOptional target for manual entries only.
multiSelectvariableEnables multiple selections.
allowManualEntryvariableAllows users to add a typed value.
  • Debounce search input, query the target list, normalize returned row values, show matching options, and persist selected values after add or remove actions.
  • Save behavior must be tested separately because UI selection can work even when persistence fails.
[
  {
    "display": "Acme Manufacturing",
    "value": "SUP-1024",
    "isManual": false,
    "source": "selected"
  }
]

Rich text editor with variable insertion concept

Help users create formatted content while inserting approved placeholders or values from Yeeflow variables.

ParameterTypePurpose
initialContentFieldvariableField or variable containing existing content.
saveToFieldvariableField where final content is saved.
availableVariablesvariableJSON array of insertable variables.
showToolbarvariableEnables formatting toolbar.
placeholderTextstringEmpty editor placeholder.
  • Load existing content, render an editor, provide a controlled list of insertable variables, and save the final value to the configured output target.
  • Document whether the output is HTML, plain text, or a Markdown-like format.
[
  { "label": "Customer Name", "token": "{{CustomerName}}" },
  { "label": "Request Amount", "token": "{{RequestAmount}}" }
]

Photo capture control concept

Capture or attach image evidence for inspections, site visits, issue reports, delivery confirmation, and compliance processes.

ParameterTypePurpose
saveToFieldvariableField where photo metadata or file references are saved.
maxPhotosstringMaximum number of photos allowed.
allowNotesvariableEnables notes per photo.
requirePhotovariableIndicates whether at least one photo is expected.
labelTextstringControl label.
  • Show upload or capture UI, preview selected photos, allow removal when not readonly, and save structured metadata to a configured field.
  • File handling depends on available Yeeflow runtime APIs. Document whether the template stores file IDs, URLs, base64 data, or metadata only.
[
  {
    "name": "inspection-front-door.jpg",
    "url": "https://example.com/file.jpg",
    "note": "Door frame damage visible",
    "capturedAt": "2026-05-10T08:30:00.000Z"
  }
]

Supporting implementation snippets

The source content pack includes helper snippets for normalization, writable target resolution, safe list queries, save helpers, JSON parsing, selected item dedupe, readonly behavior, and loading or error states. Use these as authoring aids for templates, not as complete copy-paste components.

async function queryItemsSafe(options: {
  yeeSDKClient: any;
  listId: string;
  fields?: string[];
  pageIndex?: number;
  pageSize?: number;
  filters?: any[];
}) {
  const client = options.yeeSDKClient;
  if (!client || !client.lists || typeof client.lists.queryItems !== 'function') {
    return { rows: [], raw: null, errorText: 'Yeeflow data client is not available.' };
  }

  const pageIndex = options.pageIndex || 1;
  const pageSize = options.pageSize || 20;
  const result = await client.lists.queryItems({
    listId: options.listId,
    dataListId: options.listId,
    fields: options.fields || [],
    fieldIds: options.fields || [],
    pageIndex,
    pageNo: pageIndex,
    pageSize,
    filters: options.filters || [],
  });

  const rows =
    (result && result.items) ||
    (result && result.Items) ||
    (result && result.data && result.data.items) ||
    (Array.isArray(result) ? result : []);

  return { rows: Array.isArray(rows) ? rows : [], raw: result, errorText: '' };
}