Docs
On this page
reference2 min readApplication: Platform

Client form API

Methods of current in client scripts, which read and set form fields, make them required, read-only or hidden, and show or hide layout elements.

In a client script, such as a UI event, current is the record open on the form. Use it to read and set field values, change how fields behave and show or hide layout elements while the user works on the form.

Get an instance

current is ready to use. Each field of the record is a function on it, named as the field is named.

// Read the value. For a reference field this is the record ID.
let requestedFor = current.RequestedFor();

// Read the display value. For a reference field this is the name.
let requestedForName = current.RequestedFor.displayValue();

// Set the value
current.ShortDescription("<short description>");

// Call a field function
current.RequestedFor.required(true);

A field that is not on the form still answers. Its functions do nothing and return null or false, and existsOnForm() returns false.

Field functions

Call these as current.<FieldName>.<function>(). A function that takes a boolean sets the state when you pass one and returns the current state when you do not.

Method Returns Description Since
visible(show) Boolean Shows or hides the field. 1.11
required(isRequired) Boolean Makes the field mandatory or optional. 1.11
readOnly(isReadOnly) Boolean Makes the field read-only or editable. 1.11
ignoreHasChanged(ignore) Boolean When true, a script can set the field without marking the form as changed. 1.11
displayValue() String The display value. For a reference field this is the referenced record’s name. 1.11
displayValue(text) Nothing Sets the display value. 1.11
getValue() Any The value, the same as current.<FieldName>(). 1.11
hasValue() Boolean True when the field has a value. 1.11
isEmpty() Boolean True when the field has no value. 1.11
hasChanged() Boolean True when the value has changed since the form loaded. 1.11
existsOnForm() Boolean True when the field is on the form. 1.11
fieldName() String The field name. 1.11
fieldLabel() String The field label, in the user’s language. 1.11
fieldType() String The field type. 1.11
setCssClass(className) Nothing Sets a CSS class on the field, for example a class from a portal style. 1.11
getCssClass() String The CSS class set on the field. 1.11
setStyle(property, value) Nothing Sets one CSS style property on the field. 1.11
field() Field The underlying field object. 1.11
Method Returns Description Since
setFocus() Boolean Moves the cursor to the field, opening any tab or collapsed sidebar that hides it. Returns false when the field is hidden or cannot take focus. 2027.1

Record functions

Call these on current itself.

Method Returns Description Since
getID() String The record ID. 1.11
isNewRecord() Boolean True when the record has not been saved yet. 1.11
getTableName() String The table name. 1.11
getTableDisplayName() String The table name in the user’s language. 1.11
hasField(name) Boolean True when the form holds the field. 1.11
getFieldValue(name) Any The value of the named field. 1.11
setFieldValue(name, value) TableRecord Sets the value of the named field. 1.11
hasChanged() Boolean True when any field has changed since the form loaded. 1.11
hasChangedForNotIgnoredFields() Boolean The same, leaving out fields set to ignore changes. 1.11
hasChangedFor(filter) Boolean The same, checking only the fields for which filter(field) returns true. 1.11
saveRequiredState(onceOnly) Nothing Remembers which fields are mandatory. With onceOnly true, a state already saved is kept. 1.11
resetRequired() Nothing Puts back the mandatory state that saveRequiredState() saved. 1.11
getUIElements(formID) UI elements The layout element with that Form ID, such as a heading, panel, container or tab. 1.11

Layout element functions

getUIElements(formID) finds a layout element that is not a field. Give the element a Form ID in the form builder first, then call these on the result.

Method Returns Description Since
visible(show) Nothing Shows the element when show is true and hides it when show is false. 1.11
isVisible() Boolean True when the element is shown. 1.11
selectTab() Nothing Makes the element the active tab. 1.11
isTabActive() Boolean True when the element is the active tab. 1.11
addClass(className) Nothing Adds a CSS class to the element. 1.11
removeClass(className) Nothing Removes a CSS class from the element. 1.11
width(size) Nothing Sets the element’s width in the layout: "one-third", "two-thirds", "half" or "full". 1.11

One tab is always active. Hiding the active tab does not make another tab active, so call selectTab() on the tab you want.

Examples

Make a field mandatory for one value

// <FieldName> is a field on the form
if (current.WorkflowStatus() == "<status code>") {
    current.<FieldName>.required(true);
} else {
    current.<FieldName>.required(false);
}

Show a container and select a tab

current.getUIElements("authentication-container").visible(true);
current.getUIElements("authentication-tab").selectTab();

Check a field before you use it

Servicely Script

[
    current.RequestedFor.existsOnForm(),
    current.RequestedFor.fieldLabel(),
    current.RequestedFor.required()
];

Response

[true, "<field label>", false]
Last updated 3 December 2026commit 6777698daac5Chris Jones
Back to top