Skip to content

This how-to is for builders who need a small piece of browser behaviour that no setting offers — a warning when a late record opens, a class added to a list so your CSS can style it, a log line while you test. You will learn where to write an entity or view script, when each script runs, exactly what a script can read, and a set of recipes you can copy. Scripts are available Since 1.8.

You need:

  • Permission to edit the entity (for an entity script) or the view (for a view script). See Data Views & Faces for views and Create and design an entity for entities.
  • Some JavaScript. A script is plain JavaScript; there is nothing to install.

You can write a script on the entity, on a view, or on both.

Write it onWhen to use itWhere
The entityThe behaviour belongs to the records themselves, wherever they are opened.Administration › Applications › Data Entities, select the entity, then the Web settings tab.
A viewThe behaviour belongs to one way of presenting the records.Open the view from the entity’s Views tab, then its Web settings tab.
  1. Open Administration › Applications › Data Entities and select the entity.
  2. Select the Web settings tab. It shows Initialization Scripts, with one code editor per face.
  3. Type your script into the editor of the face it should run on — for example View Entry.
  4. Select Save.

The Web settings tab appears only when you may edit the entity and the entity is not archived.

  1. Open the entity, select the Views tab and open the view.
  2. Select the Web settings tab. Under the custom styles you will find Initialization Scripts.
  3. Type your script into the editor of the face it should run on.
  4. Save the view.

A view shows an editor only for the faces it actually uses: Create Entry and Update Entry when Editing entries allows creating or editing, View Entry when the record’s details are on, and one editor per list face you have switched on. A Proxy View has no Web settings tab.

Each editor belongs to one face. The script runs once when that screen opens.

EditorRuns whencontext.entry
Create EntryThe create form opens.null (the record does not exist yet)
Update EntryThe edit form opens.The record being edited
View EntryThe record’s details open.The record shown
Table ViewThe list is shown as a table.null
Kanban ViewThe list is shown as a kanban board.null
Calendar ViewThe list is shown as a calendar.null
Timeline ViewThe list is shown as a timeline.null
Tree ViewThe list is shown as a tree.null
Badge ViewThe list is shown as cards (the Card view face).null

A list-face script runs when the list loads and again when someone switches to that face. It runs once for the whole list, not once per row or card, and it does not receive the listed records. The counter face has no script.

Order. When both have a script for the same face, the view’s script runs first, then the entity’s. If one of them fails, the other still runs.

Which scripts run where.

Where the screen is openedScripts that runcontext.viewcontext.get('el')
In Administration, from the entity itselfThe entity’s onlynullnull
Through a view (the view’s own page, or the record opened from it)The view’s, then the entity’sThe viewnull
A View widget on a page (list faces)The view’s, then the entity’sThe viewThe widget’s own element

A script receives one object, context. Use it for everything; inside a script, window, document and console are not the browser’s — reach them through context.get('w').

MemberWhat it isAvailable on
context.entityThe entity: normalizedName, name ({ en, ar }), fields (each with normalizedName, name, dataType) and the rest of its design.Every face
context.viewThe view: normalizedName, name ({ en, ar }) and the rest of its design. null when no view is involved.Screens opened through a view
context.entryThe record: id, value (the field values, keyed by each field’s normalized name), state, creationInfo and updateInfo (doneAt, doneBy). null on the create form and on list faces.Update Entry, View Entry
context.entriesAn array of records. On a form or details screen it holds the one record, [entry]; on the create form and on list faces it is empty, []. It is never null.Every face
context.popupManagerThe platform’s dialog service. Its one method, open(component, config), needs a platform screen component, which a script does not have. For a simple message use context.get('w').alert(...) instead.Every face
context.get('w')The browser window. Use it for alert, confirm, setTimeout, console and document. Inside a View widget, context.get('w').document.querySelector, querySelectorAll and getElementById search only that widget.Every face
context.get('el')The element of the View widget that ran the script, or null anywhere else.List faces inside a View widget

Good to know about values:

  • A field’s value is in context.entry.value.<normalized name> — for example context.entry.value.due_date. A field the person may not see is missing from value, so always allow for undefined.
  • A reference field holds an object with dataEntity and dataEntry (the referenced entity and record ids), not a display text.
  • There is no form object: a script can read a record but cannot set field values or follow what someone types. See Things a script cannot do.

Each recipe names the editor to put it in. Start every recipe by checking that what it needs is there.

Put this in any editor while you build, open the screen and look in the browser’s developer console.

const w = context.get('w');
w.console.log('[my-script]', {
entity: context.entity?.normalizedName,
view: context.view?.normalizedName ?? '(none)',
entry: context.entry?.id ?? '(none)',
values: context.entry?.value,
});

View Entry. Shows a message when the record’s due date has passed.

const entry = context.entry;
if (!entry) return;
const due = entry.value?.due_date; // your field's normalized name
if (!due) return; // empty or hidden: nothing to check
if (new Date(due) < new Date()) {
context.get('w').alert('This request is past its due date.');
}

View Entry or Update Entry. Reads the label from the entity, in the language the page is shown in.

const entry = context.entry;
if (!entry) return;
const rtl = context.get('w').document.documentElement.dir === 'rtl';
const lang = rtl ? 'ar' : 'en';
const field = context.entity?.fields?.find((f) => f.normalizedName === 'priority');
const label = field?.name?.[lang] ?? field?.name?.en ?? 'Priority';
if (!entry.value?.priority) {
context.get('w').alert(`${label} is not set on this record yet.`);
}

Remind people of a rule when they start a new record

Section titled “Remind people of a rule when they start a new record”

Create Entry on a view. There is no record yet, so use only entity and view.

// Only for the portal view, not for every way of creating a record.
if (context.view?.normalizedName !== 'asset_request_portal') return;
context.get('w').alert('Attach the signed approval form before you save.');

Update Entry.

const info = context.entry?.updateInfo ?? context.entry?.creationInfo;
if (!info?.doneAt) return;
const days = (Date.now() - new Date(info.doneAt).getTime()) / 86400000;
if (days > 30) {
context.get('w').alert('This record has not changed for over a month. Check it is still current.');
}

Mark a list on a page so your CSS can style it

Section titled “Mark a list on a page so your CSS can style it”

Table View (or any list face). Works inside a View widget on a page; the class goes on that widget only, even when the same view appears twice on the page.

const el = context.get('el');
if (!el) return; // not inside a View widget
el.classList.add('urgent-list');

Then style .urgent-list in the page or view CSS — see Style a view with custom CSS.

Table View, inside a View widget. getElementById searches only this widget, so an id that repeats on the page still finds the right element.

if (!context.get('el')) return;
const doc = context.get('w').document;
const banner = doc.getElementById('my-banner'); // an element your content provides
if (banner) {
banner.textContent = context.view?.name?.en ?? '';
}

A list-face script can run more than once — for example when someone switches faces and back. Mark the element the first time.

const el = context.get('el');
if (!el || el.dataset.myScriptDone) return;
el.dataset.myScriptDone = 'yes';
el.classList.add('urgent-list');

If the element you need is not on screen yet when the script starts, try again a moment later.

const w = context.get('w');
const el = context.get('el');
if (!el) return;
w.setTimeout(() => {
const rows = el.querySelectorAll('tr');
w.console.log('[my-script] rows on screen:', rows.length);
}, 300);
You want toUse instead
Fill in a field when the form opensA field’s starting value, or a button that pre-fills the form.
Compute a value from other fieldsA calculated field or an expression.
React while someone typesField validation and the form’s own rules. A script runs once, when the screen opens.
Count or total the records in a listTotals and grouping or a summary. A list-face script does not receive the records.
Work on records people selectA script button with Multiple Entries.
Save or change dataA custom action button. A script only runs in the browser.
  • Keep scripts small. One task per script. Long logic is hard to check and runs for everyone who opens the screen.
  • Check before you use. entry, view and get('el') can be null, and a field may be missing from entry.value. Use ?. and return early.
  • Stay inside the widget. For DOM changes in a View widget, start from context.get('el'), so two copies of the same view on one page do not affect each other.
  • Test on the real screen. The Preview panel in the view designer does not run scripts. Save, open the screen as a person would, and try each face you wrote a script for.
  • Read the console. When a script fails, the error is written to the browser’s developer console as [EntityScript] error in view face "viewEntry" (or entity), with the view’s and entity’s normalized names. The screen keeps working.
  • Log with context.get('w').console. Plain console.log does not work inside a script.
  • View script not running? Screens opened from the entity in Administration run only the entity’s script. Open the screen through the view to run the view’s script too.

Platform 1.10.0 · Backend 1.11.0-alpha.11 · Frontend 1.11.0-alpha.6 · Mobile 1.10.2 · Chart 1.11.8 · Gateway 2.6.11 · MCP 0.2.0 · Grafana DS 1.2.0Docs build 2026-11-27