MCPcopy Index your code
hub / github.com/simstudioai/sim / extractTitle

Function extractTitle

apps/sim/connectors/airtable/airtable.ts:48–64  ·  view source on GitHub ↗

* Extracts a human-readable title from a record's fields. * Prefers the configured title field, then falls back to common field names.

(fields: Record<string, unknown>, titleField?: string)

Source from the content-addressed store, hash-verified

46 * Prefers the configured title field, then falls back to common field names.
47 */
48function extractTitle(fields: Record<string, unknown>, titleField?: string): string {
49 if (titleField && fields[titleField] != null) {
50 return String(fields[titleField])
51 }
52 const candidates = ['Name', 'Title', 'name', 'title', 'Summary', 'summary']
53 for (const candidate of candidates) {
54 if (fields[candidate] != null) {
55 return String(fields[candidate])
56 }
57 }
58 for (const value of Object.values(fields)) {
59 if (typeof value === 'string' && value.trim()) {
60 return value.length > 80 ? `${value.slice(0, 80)}…` : value
61 }
62 }
63 return 'Untitled'
64}
65
66/**
67 * Parses the cursor format: "offset:<airtable_offset>"

Callers 1

recordToDocumentFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected