docs/docs/en/runjs/context/get-value.md
In editable field scenarios such as JSField and JSItem, use this to get the latest value of the current field. Combined with ctx.setValue(v), it enables two-way binding with the form.
| Scenario | Description |
|---|---|
| JSField | Read user input or the current form value in editable custom fields. |
| JSItem | Read the current cell value in editable items of tables/sub-tables. |
| JSColumn | Read the field value of the corresponding row during table column rendering. |
Note:
ctx.getValue()is only available in RunJS contexts with form binding; it does not exist in scenarios without field binding, such as workflows or linkage rules.
getValue<T = any>(): T | undefined;
undefined if the field is not registered or not filled.ctx.getValue() retrieves values in the following order:
If the form has not finished rendering or the field is not registered, it may return
undefined.
const current = ctx.getValue();
if (current == null || current === '') {
ctx.render(<span>Please enter content first</span>);
} else {
ctx.render(<span>Current value: {current}</span>);
}
const { Input } = ctx.libs.antd;
// Read current value as default value
const defaultValue = ctx.getValue() ?? '';
ctx.render(
<Input
defaultValue={defaultValue}
onChange={(e) => ctx.setValue(e.target.value)}
/>
);
getValue for two-way binding.js-field:value-change - Container event triggered when external values change, used to update the display.