Autocomplete suggestions
Assist-text fields use Studio scripts to provide suggestions while allowing free-text input.
Configure a suggestion script
- Create a Studio server script. Paste the example into its TypeScript entry file, then compile, save, and publish
- Open Work > Forms, select the form, then open Field Design and create or edit an Assist Text field
- Set Suggestion Source to Studio Script, select the script and entry file, and save
- Open the form create or edit page to test suggestions
Readonly tables, details, and filter conditions do not execute suggestion scripts.
Script function
Use built-in types without imports. The optional second parameter is context: StudioScriptContext. Use field.autocompleteSuggestions for binding-aware compilation.
// Purpose: Test dynamic suggestions for assist-text fields.
// Constraints: Return text only; no business data access or mutations.
export default async function main(
payload: AutocompleteSuggestionsPayload,
): Promise<AutocompleteSuggestionsResult> {
const candidates = [
'Product Manager',
'Project Manager',
'Frontend Engineer',
'Backend Engineer',
'Test Engineer',
'Sales Manager',
];
const query = payload.input.query.trim().toLowerCase();
if (!query) return { suggestions: [] };
return {
suggestions: candidates.filter((text) =>
text.toLowerCase().includes(query),
),
};
}
Input Payload
| Property | Type | Meaning |
|---|---|---|
schema | 'soln.runtime-context/v1' | Runtime context version |
source.type | 'autocomplete_suggestions' | Suggestion source |
source.scope | 'main' | 'child' | Main or child field |
source.fieldApiName | string | Current field API name |
form | RuntimeFormRef | null | Source form |
draft?.data | Record<string, unknown> | Current parent draft values |
child?.row?.data | Record<string, unknown> | Current child-row values |
selection.childRows | RuntimeChildRow[] | Available child rows |
input.query | string | Query text; only requested after non-empty input |
runtime.locale | string | Runtime locale |
runtime.timezone | string | Runtime timezone |
Read fields by API name, such as payload.draft?.data.department. This event does not preload persisted records; record is null.
Response
type AutocompleteSuggestionsResult = {
suggestions: string[];
};
Each text is both displayed and inserted. No label, value, or effects properties are needed.
- Return
{ suggestions: [] }for no matches - Surrounding whitespace, empty texts, non-strings, and duplicates are removed. Order is preserved
- The runtime accepts at most 100 valid texts per execution
- Object options
[{ label, value }]are not accepted - Queries use a 250ms debounce. Scripts filter using
input.query; the frontend also applies case-insensitive substring matching - Execution failures leave suggestions empty without preventing free-text input
Test steps
- Focus an empty field: no suggestions appear until text is entered
- Enter “Engineer” to see three matches, or “Manager” to see three matches
- Select “Product Manager” to insert that exact text
- Enter “Designer”: no suggestions appear, but the text can still be saved