Skip to content

UI builder - Studio API

Pages

To execute Page APIs, take a look at the examples below:

Api.page.save("1001","My Page Name");
Api.page.setFieldValue('MyFieldID', "MyFieldValue")

setFieldValue

Sets the value of a specific field on the page

Api.page.setFieldValue(field: string, value: any): void;
Parameter Type Description
field string The Field value to be set
value any The value to be set inside the field

setFieldsValue

Sets several fields at once, from a key-value map

Api.page.setFieldsValue(values: Record<string, any>): void;
Parameter Type Description
values Record Key-value map of field id → value

setFieldValue is a one-line wrapper around this function.

getFieldValue

Retrieves the Field value from the page

Api.page.getFieldValue(field: string): any;
Parameter Type Description
field string The Field value to get

Field ids

Both getFieldValue and setFieldValue / setFieldsValue accept more than a plain field id:

  • Nested fields are addressed with a dot, e.g. group.title.
  • A literal dot inside an id is escaped as \..
  • Table rows are addressed with $ and the row index, e.g. myTable.$0.name for the name column of the first row.
  • Vertex sub-values are addressed as x, y and z, e.g. position.x.

payload

Returns all the Payload

Api.page.payload: any;      // read-only

save

Saves the current page, optionally renumbering or renaming it

Api.page.save(num?: string, name?: string, overwrite?: boolean): Promise<any>;
Parameter Type Description
num string The Page ID of the Page to be saved as
name string The name of the Page to be saved as
overwrite boolean Overwrite an existing page with that number

Warning

num must be digits only. A string that is not all digits throws "Page Num has to be digits only"; anything that is neither a string, a number nor undefined throws "Page num has to be a digits only". A number is accepted and rounded to a whole number.

saveAs

Always creates a new page, optionally with a page number and name

Api.page.saveAs(pageNum?: string, name?: string, overwrite?: boolean): Promise<any>;
Api.page.saveAs(options: ISaveAsOptions): Promise<any>;
Parameter Type Description
pageNum string The Page ID of the new Page to be saved as
name string The name of the new Page to be saved as
overwrite boolean Overwrite an existing page with that number

ISaveAsOptions is { pageNum?, name?, overwrite?, position? }, where position is { after?: number } or { before?: number }. The options form is the only way to control where the new page lands in the playlist.

The same digits-only rule as save applies to the page number.

num

Get or set the Page ID of the Page

Api.page.num: string;       // read/write

Assigning a value that is not digits-only is ignored.

name

Get or set the Name of the Page

Api.page.name: string;      // read/write

description

Get or set the Description of the Page

Api.page.description: string;   // read/write

channel

Get or set the channel the Page is assigned to

Api.page.channel: string;   // read/write

readOnly

Get or set whether the Page is read-only

Api.page.readOnly: boolean; // read/write

color

Get or set the Page colour

Api.page.color: string;     // read/write

Warning

The value must be a hex colour in #RRGGBB or #RRGGBBAA format. Anything else throws "color must be a hex color in #RRGGBB / #RRGGBBAA format".

tabToField

Moves the cursor to a field on the page

Api.page.tabToField(field: string): Promise<any>;
Parameter Type Description
field string The Field ID to tab to

mos.metadata

Reads and writes the page's MOS external metadata

Api.page.mos.metadata.get(schema?: string): any;
Api.page.mos.metadata.set(schema: string, scope?: string, payload?: string): Promise<any>;

get with no argument returns every metadata entry on the page; with a schema it returns the matching entry, compared case-insensitively. set takes a schema, scope and payload, or an object or array of such objects.

storage

Per-page storage that travels with the page

Api.page.storage

See Storage.