Custom Index Behavior Reference¶
This page lists every object a Custom Behavior script can use, with exact names, signatures and value formats. It also lists what each server run does with the result. Names are case-sensitive. For what a Custom Behavior is and where you author it, read the Introduction.
All members¶
| Member | What it does |
|---|---|
context.username |
The signed-in user's identity name |
context.usergroups |
The user's group names |
context.app |
The app that shows the panel |
RuntimeValue |
A field's current value |
Value |
Same as RuntimeValue |
Key |
The field name |
IsVisible |
true when the field is shown |
IsEnabled |
true when the field can be edited |
IsValid |
true when no behavior marked the field invalid |
Style |
The control kind |
Choices |
The choice list of a list control |
SupportingMetadata |
Extra data other features store |
metadataKvp |
The entry of the attached field |
builder.SetFieldIsVisible |
Shows or hides a field |
builder.SetFieldIsEnabled |
Makes a field editable or read-only |
builder.SetFieldRuntimeValue |
Sets a field's value |
builder.SetFieldChoices |
Replaces a field's choice list |
builder.SetFieldIsValid |
Marks a field valid or invalid |
builder.SetFieldValidationMessage |
Adds a message under a field |
builder.SetIsVisible |
Shorthand for the attached field |
builder.SetIsEnabled |
Shorthand for the attached field |
builder.SetRuntimeValue |
Shorthand for the attached field |
builder.SetIsValid |
Shorthand for the attached field |
builder.SetValidationMessage |
Shorthand for the attached field |
builder.SetChoices |
Do not use (defect) |
builder.SetFilterIsVisible |
Filter alias |
builder.SetFilterValue |
Filter alias |
builder.SetFilterIsValid |
Filter alias |
builder.SetFilterValidationMessage |
Filter alias |
helper.GenerateUUID |
Returns a random UUID |
Objects in scope¶
A script sees five objects. Nothing else is available: no console, fetch, XMLHttpRequest, require, import or timers.
| Object | What it is |
|---|---|
panel |
The fields of the content type, keyed by field name |
metadataKvp |
The panel entry of the field the behavior is attached to |
builder |
Queues changes to fields. Changes apply after the script ends. |
helper |
Utility functions |
context |
Who runs the script, and in which app |
The host joins your script to its own setup code and runs it as one block. A top-level return is a syntax error. Use if/else, or wrap your code in a function and call it.
Reserved names
The host also defines isQuickJs, customBehaviorInWeb and window before your script. They are internal. Do not use them, and do not declare variables with these names.
context¶
All property names are lowercase. Context.Username does not exist and throws a ReferenceError.
context.username¶
The signed-in user's identity name.
- Type string
- On the server
""
context.usergroups¶
The names of the groups the signed-in user belongs to.
- Type array of strings
- On the server
[]
context.app¶
The app that shows the panel.
- Type Lowercase string
- On the server
"worker"
| Value | Where the panel is |
|---|---|
webindex |
Index app |
webcapture |
Web Capture (scanning) |
upload |
Upload app |
addins |
Upload through the Office and Outlook add-ins |
view |
View app |
qc |
QC app |
search |
Document properties in Search results, and the Search bulk edit form |
interactions |
Index panel in a task layout |
taxonomy |
Preview panels in the Connections app, including Test in the Custom Behavior editor |
worker |
Every server run (see Server runs) |
If you need a value that is not in this list, write context.app into a text field once and read it.
The Search filter panel (the query form of a saved search) is a different runtime with a smaller context. See the Search Filter Behavior Reference.
panel and metadataKvp¶
panel["FieldName"] returns the entry for one field. The key is the field name as defined on the content type, with the same case and spaces.
- If no field has that name, the entry is
undefined, and reading a property of it throws aTypeError. - The panel holds only the fields of the content type: no file name, document ID, work item metadata or fields of other content types.
RuntimeValue¶
panel["FieldName"].RuntimeValue: the field's current value, as a string. Read values with this property. See Value formats.
Value¶
panel["FieldName"].Value: the same value as RuntimeValue. Prefer RuntimeValue in index panel scripts.
Key¶
panel["FieldName"].Key: the field name, as a string. Useful with metadataKvp: builder.SetFieldChoices(metadataKvp.Key, list).
IsVisible¶
panel["FieldName"].IsVisible: true when the field is shown. Reflects the state before this run.
IsEnabled¶
panel["FieldName"].IsEnabled: true when the field can be edited.
IsValid¶
panel["FieldName"].IsValid: true when no behavior has marked the field invalid.
Style¶
panel["FieldName"].Style: the control kind, as a string. For example "Textbox", "DateTime", "Boolean", "DropDownList", "Currency".
Choices¶
panel["FieldName"].Choices: the display text of each choice, as an array of strings, for list controls.
[]ornullwhen the field has no choice list.- A Filter behavior that ran earlier in the same chain has already updated it. See Compound Cascading Filter.
SupportingMetadata¶
panel["FieldName"].SupportingMetadata: extra data that other features store for the field. Treat it as read-only.
metadataKvp¶
The panel entry of the attached field. metadataKvp.RuntimeValue is the value that triggered the run.
Value formats¶
Every value is a string. Convert before you compare or calculate.
- Empty field
"", or sometimesnullorundefined. Read with(panel["F"].RuntimeValue || ""). - Boolean
"true"or"false". Compare in lowercase:(v || "").toLowerCase() === "true". - Numbers, Currency Text such as
"1250.5". UseparseFloat. Remove$and,first if users type them. - DateTime, DateTime2 An ISO 8601 string in UTC, for example
"2026-10-07T00:00:00.000Z". A date-only field holds midnight UTC. Usenew Date(value)and thegetUTC...methods. To write a date, pass an ISO string (date.toISOString()). A value the control cannot parse shows "is not a valid date" and is cleared. - Table, CheckBoxCollection A serialized string. Inspect a real value before you parse it.
builder: visibility and editing¶
Each builder method returns builder, so calls can be chained. Nothing changes on the panel until the script ends.
builder.SetFieldIsVisible¶
Shows or hides a field.
builder.SetFieldIsVisible(field, isVisible)
| Parameter | Type | Description |
|---|---|---|
field |
string | The exact field name. |
isVisible |
boolean | true shows, false hides. undefined throws. |
Returns: builder.
builder.SetFieldIsEnabled¶
Makes a field editable or read-only.
builder.SetFieldIsEnabled(field, isEnabled)
| Parameter | Type | Description |
|---|---|---|
field |
string | The exact field name. |
isEnabled |
boolean | true editable, false read-only. undefined throws. |
Returns: builder.
builder: values and choices¶
builder.SetFieldRuntimeValue¶
Sets a field's value. Unless suppressed, the target field's behaviors run after this script.
builder.SetFieldRuntimeValue(field, value, suppressBehaviors)
| Parameter | Type | Description |
|---|---|---|
field |
string | The exact field name. |
value |
string | The new value. Use "" to clear. Convert numbers with toFixed(2) or String(n). |
suppressBehaviors |
boolean, default false |
true stops the target field's behaviors from running. |
Returns: builder. Setting the attached field never runs its own behaviors again.
builder.SetFieldChoices¶
Replaces a field's choice list.
builder.SetFieldChoices(field, choices)
| Parameter | Type | Description |
|---|---|---|
field |
string | The exact field name. |
choices |
string[] | The new choices. Each string is stored as both display text and value, so a list that had separate values loses them. |
Returns: builder.
builder: validation¶
builder.SetFieldIsValid¶
Marks a field valid or invalid. An invalid field stops the user from submitting, and the user cannot override it.
builder.SetFieldIsValid(field, isValid)
| Parameter | Type | Description |
|---|---|---|
field |
string | The exact field name. |
isValid |
boolean | false marks the field invalid. true marks it valid and clears every message on the field, including messages from other behaviors. The string "false" counts as true. |
Returns: builder.
builder.SetFieldValidationMessage¶
Adds a message in red under a field. The message shows even when the field is valid.
builder.SetFieldValidationMessage(field, message)
| Parameter | Type | Description |
|---|---|---|
field |
string | The exact field name. |
message |
string | The text. Never "": an empty message shows "Could not find localized string." Do not use ;: the panel splits the message into lines at each ;. |
Returns: builder.
builder.SetFieldIsValid("PONumber", ok);
if (!ok) { builder.SetFieldValidationMessage("PONumber", "A PO number is required over 500."); }
builder: shorthands for the attached field¶
Each shorthand acts on the field the behavior is attached to, and returns builder.
builder.SetIsVisible¶
builder.SetIsVisible(isVisible): same as SetFieldIsVisible(<attached field>, isVisible).
builder.SetIsEnabled¶
builder.SetIsEnabled(isEnabled): same as SetFieldIsEnabled(<attached field>, isEnabled).
builder.SetRuntimeValue¶
builder.SetRuntimeValue(value): same as SetFieldRuntimeValue(<attached field>, value, true).
builder.SetIsValid¶
builder.SetIsValid(isValid): same as SetFieldIsValid(<attached field>, isValid).
builder.SetValidationMessage¶
builder.SetValidationMessage(message): same as SetFieldValidationMessage(<attached field>, message). Never pass "".
builder.SetChoices¶
builder.SetChoices(choices)
Do not use builder.SetChoices
The editor lists it, but the runtime has a defect: it references an undefined variable, so the behavior fails with "could not be fired". Use builder.SetFieldChoices(metadataKvp.Key, choices).
builder: filter aliases¶
These names exist for Search filter behaviors. They also work in the index panel. Each returns builder.
builder.SetFilterIsVisible¶
builder.SetFilterIsVisible(field, isVisible): same as SetFieldIsVisible(field, isVisible).
builder.SetFilterValue¶
builder.SetFilterValue(field, value): same as SetFieldRuntimeValue(field, value, true).
builder.SetFilterIsValid¶
builder.SetFilterIsValid(field, isValid): same as SetFieldIsValid(field, isValid).
builder.SetFilterValidationMessage¶
builder.SetFilterValidationMessage(field, message): same as SetFieldValidationMessage(field, message).
helper¶
helper.GenerateUUID¶
Returns a random version 4 style UUID.
helper.GenerateUUID()
- Parameters none
- Returns A string. Good enough for a reference number. Not cryptographically secure.
How operations apply¶
- Operations apply in the order you called them, after the script ends.
- For each method and field, only the last call counts. Two
SetFieldRuntimeValuecalls onTotalleave the second value. - Reads in the same run see the old values.
panel["Total"].RuntimeValuedoes not change afterSetFieldRuntimeValue("Total", ...). - A field name that does not exist in a
buildercall makes the behavior fail after the script ends, with nothing in the browser console. - Behaviors on one field run in the order shown in Change Behavior Order. Each one sees the changes of the ones before it: a Custom Behavior placed after a Filter behavior reads the choices the Filter has set.
Validation messages¶
- Call
SetFieldIsValidbeforeSetFieldValidationMessagein the same run. In the other order, the message is set and then cleared. SetFieldIsValid(field, true)clears all messages on the field, also messages from other behaviors on that field.- All Custom Behaviors share one valid flag per field. If two scripts validate the same field, the one that runs last decides. Put each field's rules in one script.
When behaviors run¶
- Panel load Every behavior on every field runs, in field order.
- Field change The behaviors on that field run. On a field with a default value behavior, picking the default value again also runs them.
- Set by a behavior The target field's behaviors run, unless suppressed.
- Server See Server runs.
Server runs¶
On the server every behavior on every field runs once per document, in V8, with context = { username: "", usergroups: [], app: "worker" }.
- Nothing is on screen, so visibility, enabled state, choices and messages have no effect. Only values and validity count.
- A document counts as marked as indexed when it gets
Generalmetadata keyCS5MarkedAsIndexed="true".
Index Your Documents step¶
Runs behaviors on each document when the work item reaches the step.
- Scope The step setting Validation Behaviors Only limits the run to Validation, Required and Custom behaviors, so Custom Behaviors always run.
- Writes When the content type has behaviors, the step writes every field value back.
- Marked as indexed When no field is invalid and at least one field has a value.
- Next The step setting Index Document Type then decides whether the work item stops for a person.
Run Indexing Behaviors step¶
An automated step that only runs behaviors.
- Writes When the content type has behaviors, it writes every field value back, also on a document with an invalid field.
- Marked as indexed When no field is invalid and at least one field has a value.
- Behaviors fail The document is skipped and reported as
Document <id> failed to Invoke Behaviors. - No content type The step fails:
Document does not have a Content Type specified. Unable to Run Behaviors on Document.
Start QC Task step¶
When the setting Mark Valid Documents as Indexed is Yes (the default), the step runs behaviors on each document that has a content type, before it creates the QC task. Documents with no content type are skipped.
- A document with no invalid field and at least one value is marked as indexed. Only the values that behaviors changed are written back.
- A document with an invalid field, or with no values, gets no writes at all. Values that behaviors changed on it are discarded.
- When Allow Straight Through Processing is Yes (default No) and every document in the work item was marked as indexed, the step creates no task and the work item moves on.
The step needs the Interactions and QC features.
Search bulk edit¶
The bulk edit form runs behaviors in the browser (context.app is "search"). The preview then runs behaviors on the server for each selected document when the saved search's bulk edit is set to run behaviors (all behaviors, or validation only). Invalid fields show in the preview with their messages.
Runtimes¶
| Where | Engine and limit |
|---|---|
| Browser index panel | QuickJS (WebAssembly), 5 seconds per run |
| Server | V8, a new engine per run, 5 seconds per run |
| Search filter panel | QuickJS, 1.5 seconds per run |
When the limit is reached, the run stops.
- Browser Shows "Behavior Custom Behavior could not be fired." on the attached field.
- Server Logs
Script execution interrupted by host. - Debug See Debugging Custom Index Behaviors.
Write ES5
QuickJS supports ES2019 syntax but has no Intl, so toLocaleString does not format numbers or dates by locale. Write scripts in plain ES5 style (var, function) so they run the same in both engines.